[Python-Dev] PEP 446: Open issues/questions

Victor Stinner victor.stinner at gmail.com
Fri Aug 2 01:59:18 CEST 2013

    2013/7/30 Richard Oudkerk <shibturn at gmail.com>:
> The documentation for STARTUPINFO says this about STARTF_USESTDHANDLES:
>   If this flag is specified when calling one of the process creation
>   functions, the handles must be inheritable and the function's
>   bInheritHandles parameter must be set to TRUE.
> So, as I said, if you redirect the streams then you inherit all inheritable
> handles.

Outch! It means that all Python applications redirecting at least one
standard stream inherit almost all open handles, including open files.
The situation on Windows is worse than what I expected.

If I understood correctly, making new handles and new file descriptors
non-inheritable by default on Windows would improve the situation
because they will not stay "open" (they are not inheritable anymore)
in child processes.

On Windows, a file cannot be removed if at least one process opened
it. If you create a temporary file, run a program, and delete the
temporary file: the deletion fails if the program inherited the file
and the program is not done before the deletion. Is this correct?

I didn't check this use case on Windows, but it is similar to the
following Haskell (GHC) issue:


More information about the Python-Dev mailing list