Message284817
Though Python has taken measures to mark handles as non-inheritable there is still a possible race due to having to create inheritable handles while creating processes with stdio pipes (subprocess).
Attached is a Patch that implements subprocess.Popen(close_fds=True) with stdio handles on Windows using PROC_THREAD_ATTRIBUTE_HANDLE_LIST, which plugs that race completely.
I implemented this by adding the attribute STARTUPINFO._handleList, which when passed to _winapi.CreateProcess, will be passed to CreateProcess as a PROC_THREAD_ATTRIBUTE_HANDLE_LIST. subprocess.py can than use this attribute as needed with inherit_handles=True to only inherit the stdio handles.
The STARTUPINFO._handleList attribute can also be used to implement pass_fds later on. Though the exact behavior of how to convert a file descriptor list to a handle list might be a bit sensitive, so I left that out for now.
This patch obviously doesn't support Windows XP but Python 3 doesn't support XP anymore either. |
|
Date |
User |
Action |
Args |
2017-01-06 12:38:36 | Segev Finer | set | recipients:
+ Segev Finer, paul.moore, vstinner, tim.golden, Bernt.Røskar.Brenna, sbt, zach.ware, steve.dower |
2017-01-06 12:38:36 | Segev Finer | set | messageid: <1483706316.5.0.553505188343.issue19764@psf.upfronthosting.co.za> |
2017-01-06 12:38:36 | Segev Finer | link | issue19764 messages |
2017-01-06 12:38:36 | Segev Finer | create | |
|