]> granicus.if.org Git - python/commit
bpo-19764: Implemented support for subprocess.Popen(close_fds=True) on Windows (...
authorSegev Finer <segev208@gmail.com>
Mon, 18 Dec 2017 09:28:19 +0000 (11:28 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 18 Dec 2017 09:28:19 +0000 (10:28 +0100)
commitb2a6083eb0384f38839d3f1ed32262a3852026fa
treed95a4dd911ebc05549fe54dee0b76c67fe5c727a
parent87010e85cb37192d63b1a30e5fabba307ad5a3f5
bpo-19764: Implemented support for subprocess.Popen(close_fds=True) on Windows (#1218)

Even though Python marks any handles it opens as non-inheritable there
is still a race when using `subprocess.Popen` since creating a process
with redirected stdio requires temporarily creating inheritable handles.
By implementing support for `subprocess.Popen(close_fds=True)` we fix
this race.

In order to implement this we use PROC_THREAD_ATTRIBUTE_HANDLE_LIST
which is available since Windows Vista. Which allows to pass an explicit
list of handles to inherit when creating a process.

This commit also adds `STARTUPINFO.lpAttributeList["handle_list"]`
which can be used to control PROC_THREAD_ATTRIBUTE_HANDLE_LIST
directly.
Doc/library/subprocess.rst
Doc/whatsnew/3.7.rst
Lib/subprocess.py
Lib/test/test_subprocess.py
Misc/ACKS
Misc/NEWS.d/next/Windows/2017-08-18-18-00-24.bpo-19764.ODpc9y.rst [new file with mode: 0644]
Modules/_winapi.c
Modules/clinic/_winapi.c.h