File operations in base and fork+exec

John Lato jwlato at
Fri Jun 23 10:58:33 UTC 2017

Big +1. I got bitten by this a few years ago and was going to do some work
on the Unix package to make it easier to do this properly but never got
around to it.

On Fri, Jun 23, 2017, 10:46 Merijn Verstraaten <merijn at>

> Hi!
> So I realise proposing backwards incompatible changes to base is tilting
> at windmills, but I just noticed that most (all?) file operations in base
> don't open files with O_CLOEXEC, which basically means that every open
> Handle/file descriptor gets leaked to every single subprocess you fork+exec
> from Haskell. This seems highly undesirable. For POSIX there appears to be
> an operation in base that disables this, but it doesn't seem to easily
> exported.
> I would like to propose that all operations in base open files with
> O_CLOEXEC by default and exposing an easy method to mark specific file
> descriptors to be preserved across exec (This can be achieved by using
> fcntl to remove the CLOEXEC bit from a specific fd).
> I'm not sure to what extent Windows behaviour is similar to POSIX, but in
> principle it should behave the same, I think.
> Cheers,
> Merijn
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list