#4449: GHC 7 can't do IO when demonized
------------------------------+---------------------------------------------
    Reporter:  kazu-yamamoto  |       Owner:              
        Type:  bug            |      Status:  new         
    Priority:  normal         |   Component:  Compiler    
     Version:  7.1            |    Keywords:  forkProcess 
    Testcase:                 |   Blockedby:              
          Os:  MacOS X        |    Blocking:              
Architecture:  x86            |     Failure:  None/Unknown
------------------------------+---------------------------------------------
 If a daemon is complied with GHC 7.1 with the -threaded option, the daemon
 cannot do IO. The following code is a simple echo server which
 demonstrates this bug:

 {{{
 import Control.Concurrent
 import Network
 import System.IO
 import System.Posix.Daemonize

 main :: IO ()
 main = daemonize $ do
     s <- listenOn (Service "7000")
     loop s
     return ()

 loop :: Socket -> IO ThreadId
 loop s = do
     (hdr,_,_) <- accept s
     forkIO $ echo hdr
     loop s

 echo :: Handle -> IO ()
 echo hdr = do
     str <- hGetLine hdr
     hPutStrLn hdr str
     hClose hdr
     return ()
 }}}

 If "deamonize $" is removed, this program stays in your terminal and can
 do IO.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4449>
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

Reply via email to