Phobos: Posix hands down open files to sub processes.

Marco Leise Marco.Leise at gmx.de
Sun Mar 10 10:41:40 PDT 2013


A common bug on Posix seems to be to forget to close file
descriptors not meant to stay open in child processes as this
search reveals:

http://www.google.de/search?q=%22set+FD_CLOEXEC%22+OR+%22FD_CLOEXEC+not+set%22+bug

Unlike on Windows where this is opt-in, it is opt-out and you
have to use FD_CLOEXEC, which closes the file descriptor
across an "execve" (used to execute another program).

My proposal is here to add this flag to all file descriptors
Phobos opens (files, sockets, streams) and make it a
convention for Phobos development on Posix. The assumption is
that this is the saner default nowadays, kudos to Windows here.

This issue came up in the std.process thread, where hacks
around it for the sake of OS independent behavior are
discussed.

Would this be feasible and work ?

-- 
Marco



More information about the Digitalmars-d mailing list