id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
4449,GHC 7 can't do IO when demonized,kazu-yamamoto,,"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.
",bug,closed,normal,7.0.2,Compiler,7.1,fixed,forkProcess,johan.tibell@… dastapov@…,MacOS X,x86,None/Unknown,,,,,
