Skip to content

bpo-47151: Fallback to fork when vfork fails in subprocess. #32186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,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
{
Expand Down