[Haskell-cafe] Socket not released

Donn Cave donn at avvanta.com
Mon Aug 9 10:33:05 EDT 2010

Quoth Jonathan Geddes <geddes.jonathan at gmail.com>,

>> You need to close the parent's socket in the child fork, as well as
>> the parent - if it's inherited by the child, it's held open there,
>> even if the parent closes it.
> Thanks! That did the trick.
> I did so by adding
> > close_fds = True
> to the CreateProcess record. However the documentation of
> System.Process says that this only works on Windows if std_in,
> std_out, and std_err are all set to Inherit. This is not the case in
> my program so it will not work on any nodes that run on Windows. What
> is the workaround for doing this kind of thing in Windows?

Only a guess, but I predict that it will work for your purposes,
since you're not concerned about what happens to std_in et al.

That statement in the documentation is ambiguous, so if it isn't 
convenient to just test for this, you need someone to clarify
what "doesn't work" means.

> Also since
> the file descriptor of the socket appears to be inherited by the child
> process, can I just start using it rather than closing it in both the
> parent and child and then creating a new one?

Sure!  At least from a POSIX perspective, and it would be surprising
if a Haskell implementation failed to preserve that.

	Donn Cave, donn at avvanta.com

More information about the Haskell-Cafe mailing list