aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/multiprocessing/util.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2022-04-25 16:19:39 -0700
committerGitHub <noreply@github.com>2022-04-25 16:19:39 -0700
commitcd5726fe674eaff442510eeb6c75628858be9e9f (patch)
treed311f0b144298e29596d1fb5dcc4629ec9e8647e /Lib/multiprocessing/util.py
parenteddd07f840c9a4ab0ee05ce56d98caac0f072cef (diff)
downloadcpython-cd5726fe674eaff442510eeb6c75628858be9e9f.tar.gz
cpython-cd5726fe674eaff442510eeb6c75628858be9e9f.zip
gh-91401: Add a failsafe way to disable vfork. (#91490)
Just in case there is ever an issue with _posixsubprocess's use of vfork() due to the complexity of using it properly and potential directions that Linux platforms where it defaults to on could take, this adds a failsafe so that users can disable its use entirely by setting a global flag. No known reason to disable it exists. But it'd be a shame to encounter one and not be able to use CPython without patching and rebuilding it. See the linked issue for some discussion on reasoning. Also documents the existing way to disable posix_spawn.
Diffstat (limited to 'Lib/multiprocessing/util.py')
-rw-r--r--Lib/multiprocessing/util.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py
index abbc4c5e608..790955e7b71 100644
--- a/Lib/multiprocessing/util.py
+++ b/Lib/multiprocessing/util.py
@@ -446,13 +446,15 @@ def _flush_std_streams():
def spawnv_passfds(path, args, passfds):
import _posixsubprocess
+ import subprocess
passfds = tuple(sorted(map(int, passfds)))
errpipe_read, errpipe_write = os.pipe()
try:
return _posixsubprocess.fork_exec(
args, [path], True, passfds, None, None,
-1, -1, -1, -1, -1, -1, errpipe_read, errpipe_write,
- False, False, None, None, None, -1, None)
+ False, False, None, None, None, -1, None,
+ subprocess._USE_VFORK)
finally:
os.close(errpipe_read)
os.close(errpipe_write)