mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
bpo-47151: Fallback to fork when vfork fails in subprocess. (GH-32186)
bpo-47151: Fallback to fork when vfork fails in subprocess. An OS kernel can specifically decide to disallow vfork() in a process. No need for that to prevent us from launching subprocesses.
(cherry picked from commit 4a08c4c469)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
625f6704c0
commit
9ed179b07d
2 changed files with 9 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
When subprocess tries to use vfork, it now falls back to fork if vfork
|
||||
returns an error. This allows use in situations where vfork isn't allowed
|
||||
by the OS kernel.
|
||||
|
|
@ -681,6 +681,12 @@ do_fork_exec(char *const exec_array[],
|
|||
assert(preexec_fn == Py_None);
|
||||
|
||||
pid = vfork();
|
||||
if (pid == -1) {
|
||||
/* If vfork() fails, fall back to using fork(). When it isn't
|
||||
* allowed in a process by the kernel, vfork can return -1
|
||||
* with errno EINVAL. https://bugs.python.org/issue47151. */
|
||||
pid = fork();
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue