[Python-Dev] PEP 433: Add cloexec argument to functions creating file descriptors

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Jan 14 22:44:12 CET 2013


Nick Coghlan wrote:

> The problem is the mechanism is *not the same* on Windows and POSIX -
> the Windows mechanism (noinherit) means the file won't be accessible
> in child processes, the POSIX mechanism (cloexec) means it won't
> survive exec().

But since there is no such thing as a fork without exec on
Windows, the term "cloexec" is still correct. The fd is closed
during the exec part of the fork+exec implied by spawning a
child process.

> This difference really shows up with multiprocessing,
> as that uses a bare fork() without exec() on POSIX systems, meaning
> even flagged descriptors will still be inherited by the child
> processes.

There are a lot of other ways that this difference will be
visible as well, so the difference in cloexec behaviour just
needs to be documented in the multiprocessing module along
with the rest.

> I agree with Glenn's point that "sensitive" in particular is a bad
> choice, but a more value neutral term like "protect" may still work.

I think "protect" is *far* too vague. We don't want something
so neutral that it gives no clue at all about its meaning.

-- 
Greg


More information about the Python-Dev mailing list