Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4c5dcc6

Browse filesBrowse files
authored
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>
1 parent 6eaa4ae commit 4c5dcc6
Copy full SHA for 4c5dcc6

File tree

2 files changed

+5
-0
lines changed
Filter options

2 files changed

+5
-0
lines changed

‎Lib/subprocess.py

Copy file name to clipboardExpand all lines: Lib/subprocess.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ def _use_posix_spawn():
715715
# os.posix_spawn() is not available
716716
return False
717717

718+
if ((_env := os.environ.get('_PYTHON_SUBPROCESS_USE_POSIX_SPAWN')) in ('0', '1')):
719+
return bool(int(_env))
720+
718721
if sys.platform in ('darwin', 'sunos5'):
719722
# posix_spawn() is a syscall on both macOS and Solaris,
720723
# and properly reports errors
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Introduce new ``_PYTHON_SUBPROCESS_USE_POSIX_SPAWN`` environment variable knob in
2+
:mod:`subprocess` to control the use of :func:`os.posix_spawn`.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.