Ticket #4449 (closed bug: fixed)
GHC 7 can't do IO when demonized
| Reported by: | kazu-yamamoto | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.0.2 |
| Component: | Compiler | Version: | 7.1 |
| Keywords: | forkProcess | Cc: | johan.tibell@…, dastapov@… |
| Operating System: | MacOS X | Architecture: | x86 |
| Type of failure: | None/Unknown | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

