[issue19124] os.execv executes in background on Windows
Eryk Sun
report at bugs.python.org
Tue Mar 30 14:18:06 EDT 2021
Eryk Sun <eryksun at gmail.com> added the comment:
> Even if that's just swapping the execv call for spawnv(_P_WAIT)
> and then exiting, that's fine by me
Maybe call SuspendThread() on other threads, at least the ones that can be enumerated with the threading module.
> I don't see how its behaviour would change at all, unless we're going
> well out of our way to override the CRT. Which I wouldn't want to see
> us do.
The suggestion was for Python to implement system() and spawnv[e]() using subprocess or _winapi. That would eliminate the problem of leaked handles when subprocess.Popen() is called concurrently with os.system() and os.spawn*(). However, inheritance of file descriptors cannot be reasonably implemented in that case, not without accessing private CRT data (i.e. the internal flags of each file descriptor).
If os.spawn*() has to continue supporting inheritance of file descriptors, then the idea is probably a non-starter. All we can do is hope that the CRT's common spawn code will eventually use PROC_THREAD_ATTRIBUTE_HANDLE_LIST. This feature only protects against leaked handles (particularly important for pipes) if it's used by all concurrent CreateProcessW() calls that inherit handles.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue19124>
_______________________________________
More information about the Python-bugs-list
mailing list