mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-129204: Add _PYTHON_SUBPROCESS_USE_POSIX_SPAWN environment knob (GH-132184)
* Add _PYTHON_SUBPROCESS_USE_POSIX_SPAWN environment knob Add support for disabling the use of `posix_spawn` via a variable in the process environment. While it was previously possible to toggle this by modifying the value of `subprocess._USE_POSIX_SPAWN`, this required either patching CPython or modifying it within the interpreter instance which is not always possible, such as when running applications or scripts not under a user's control. Signed-off-by: Vincent Fazio <vfazio@gmail.com> * fixup NEWS entry --------- Signed-off-by: Vincent Fazio <vfazio@gmail.com>
This commit is contained in:
parent
6eaa4aeef2
commit
4c5dcc6d82
2 changed files with 5 additions and 0 deletions
|
@ -715,6 +715,9 @@ def _use_posix_spawn():
|
|||
# os.posix_spawn() is not available
|
||||
return False
|
||||
|
||||
if ((_env := os.environ.get('_PYTHON_SUBPROCESS_USE_POSIX_SPAWN')) in ('0', '1')):
|
||||
return bool(int(_env))
|
||||
|
||||
if sys.platform in ('darwin', 'sunos5'):
|
||||
# posix_spawn() is a syscall on both macOS and Solaris,
|
||||
# and properly reports errors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue