[GHC] #1936: When lazy IO blocks, it blocks the whole runtime

GHC trac at galois.com
Mon Nov 26 21:06:24 EST 2007


#1936: When lazy IO blocks, it blocks the whole runtime
----------------------------+-----------------------------------------------
 Reporter:  guest           |          Owner:                              
     Type:  bug             |         Status:  new                         
 Priority:  normal          |      Milestone:                              
Component:  Runtime System  |        Version:  6.8.1                       
 Severity:  normal          |       Keywords:  lazy IO getContents blocking
 Testcase:                  |   Architecture:  Multiple                    
       Os:  Linux           |  
----------------------------+-----------------------------------------------
 {{{
 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 at feanor:~% ghc --make brokenio.hs -threaded +RTS -N8
 [1 of 1] Compiling Main             ( brokenio.hs, brokenio.o )
 Linking brokenio ...
 dfranke at feanor:~% sleep 5 | ./brokenio
 dfranke at feanor:~%
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1936>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list