
On 2007-10-16, Jules Bean
John Goerzen wrote:
Many systems will just try to close *all* FDs except the ones they need after a fork(). Another approach would be to maintain a global list of FDs that the Haskell thread is using, and close all of them except the pipe ends in the child.
Does this make sense to everyone? If so, I'll submit the bug on GHC.
Yes, it does make sense.
On POSIX systems it should suffice to just have haskell set CLOSE_ON_EXEC on all its fds except std{in,out,err} and special pipe fds, shouldn't it?
Do you mean FD_CLOEXEC, which can be set with fcntl()? If so, it's not defined in POSIX according to the Linux manpage. I couldn't find CLOSE_ON_EXEC in either open(2) or fcntl(2). If FD_CLOEXEC is set in the Haskell process atomically, before anything has a chance to fork off and use it, this would be an ideal solution on platforms that support it. -- John