[Haskell-cafe] createProcess interferes with sockets?

Evan Laforge qdunkan at gmail.com
Mon Apr 22 09:11:33 CEST 2013

On Sun, Apr 21, 2013 at 9:25 PM, Donn Cave <donn at avvanta.com> wrote:
> Quoth Evan Laforge <qdunkan at gmail.com>,
>> sleep = Process.createProcess (Process.proc "sleep" ["5"])
>  sleep = Process.createProcess
>         ((Process.proc "sleep" ["5"]) {Process.close_fds = True})
> - Because the client uses buffered I/O (hGetContents in this case, but
> hGet-anything would be the same), it doesn't "see" the server response
> until a) buffer full, or b) end of file (server closes connection.)
> - The server does close the connection, but after the "sleep" process
> has forked off with a copy of the connection fd.  If it doesn't close
> that fd explicitly, it holds it open until process exit (5 seconds.)

Oh I see, because the subprocess inherits the socket connection.  That
makes sense, though it's tricky.  Tricky tricky unix.  Why does fork()
have to be so complicated?  Thanks, that fixed my problem.

More information about the Haskell-Cafe mailing list