When lazy IO blocks, it blocks the whole runtime
module Main where
import Control.Concurrent
import System.IO
import qualified Data.ByteString.Lazy.Char8 as B
heartbeat :: IO ()
heartbeat = do threadDelay 1000000
putStrLn "."
heartbeat
main :: IO ()
main = do forkIO heartbeat
c <- B.getContents
h <- openFile "/dev/null" WriteMode
B.hPut h c
This should produce a heartbeat while it's waiting on stdin, but it doesn't, even with SMP:
dfranke@feanor:~% ghc --make brokenio.hs -threaded +RTS -N8
[1 of 1] Compiling Main ( brokenio.hs, brokenio.o )
Linking brokenio ...
dfranke@feanor:~% sleep 5 | ./brokenio
dfranke@feanor:~%
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | df@dfranke.us |
| Operating system | |
| Architecture | Multiple |