#2363: getChar cannot be interrupted with -threaded
-------------------------------+--------------------------------------------
Reporter: simonmar | Owner:
Type: bug | Status: new
Priority: high | Milestone: 6.10 branch
Component: libraries/base | Version: 6.8.2
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
-------------------------------+--------------------------------------------
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)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2363>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs