Ticket #2363 (closed bug: fixed)
getChar cannot be interrupted with -threaded
| Reported by: | simonmar | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 6.10 branch |
| Component: | libraries/base | Version: | 6.8.2 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
Now that stdin, stdout and stderr are left in blocking mode, when using the threaded RTS, I/O operations on these handles are no longer interruptible. We ought to do something about this.
module Main where
import Control.Monad
import System.Posix.Signals
import Control.Concurrent
import Control.Concurrent.MVar
import System.IO
main = do
hSetBuffering stdin NoBuffering
hSetEcho stdin False
mv <- newEmptyMVar
let handler = putMVar mv Nothing
installHandler sigINT (CatchOnce handler) Nothing
tid <- forkIO (myGetChar mv)
c <- takeMVar mv
when (c==Nothing) $ do
killThread tid
putStrLn ("Result: " ++ show c)
myGetChar mv = do
c <- getChar
putMVar mv (Just c)
Change History
Note: See
TracTickets for help on using
tickets.
