2013/1/7 Victor Stinner <victor.stinner@gmail.com>:
">

(original) (raw)




On Mon, Jan 7, 2013 at 4:03 PM, Benjamin Peterson <benjamin@python.org> wrote:
2013/1/7 Victor Stinner <victor.stinner@gmail.com>:
> Hi,
\>
\> I would like add a new flag to open() mode to close the file on exec:
\> "e". This feature exists using different APIs depending on the OS and
\> OS version: O\_CLOEXEC, FD\_CLOEXEC and O\_NOINHERIT. Do you consider
\> that such flag would be interesting?

I'm not sure it's worth cluttering the open() interface with such a
non-portable option. People requiring such control should use the
low-level os.open interface.

The ability to supply such flags really belongs on \_all\_ high or low level file descriptor creating APIs so that things like subprocess\_cloexec\_pipe() would not be necessary:�http://hg.python.org/cpython/file/0afa7b323abb/Modules/\_posixsubprocess.c#l729

I'm not excited about raising an exception when it isn't supported; it should attempt to get the same behavior via multiple API calls instead (thus introducing a race condition for threads+fork+exec, but there is no choice at that point and it is what most people would want in that situation regardless). Not being supported will be such an extremely rare situation for any OS someone runs a Python 3.4 program on that that detail is pretty much a non-issue either way as far as I'm concerned.

-gps