
* Evan Laforge
On Sun, Apr 21, 2013 at 9:25 PM, Donn Cave
wrote: Quoth Evan Laforge
, 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?
You probably want to set FD_CLOEXEC flag on your sockets. This will cause execve to close them in the child process. Roman