8000 gh-94518: [_posixsubprocess] Replace variable validity flags with reserved values by arhadthedev · Pull Request #94687 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-94518: [_posixsubprocess] Replace variable validity flags with reserved values #94687

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 14 commits into from
Jan 14, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Check num_groups for emptiness, not groups_list
`num_groups < 0` already implies `groups_list == Py_None` because
`num_groups = PySequence_Size(groups_list)` does this check for us.

Also, it guarantees that `groups_list == Py_None` <=> `groups == NULL`;
it allows to replace `groups_list != Py_None ? groups : NULL` with just
`groups` in a call of `do_fork_exec()`.
  • Loading branch information
arhadthedev committed Jul 27, 2022
commit c9bf4f64f74a7ff266b5db8df7d899fba3ba87e7
4 changes: 2 additions & 2 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
/* Use vfork() only if it's safe. See the comment above child_exec(). */
sigset_t old_sigs;
if (preexec_fn == Py_None && allow_vfork &&
uid == (uid_t)-1 && gid == (gid_t)-1 && groups_list == Py_None) {
uid == (uid_t)-1 && gid == (gid_t)-1 && num_groups < 0) {
/* Block all signals to ensure that no signal handlers are run in the
* child process while it shares memory with us. Note that signals
* used internally by C libraries won't be blocked by
Expand All @@ -1021,7 +1021,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
p2cread, p2cwrite, c2pread, c2pwrite,
errread, errwrite, errpipe_read, errpipe_write,
close_fds, restore_signals, call_setsid, pgid_to_set,
gid, num_groups, groups_list != Py_None ? groups : NULL,
gid, num_groups, groups,
uid, child_umask, old_sigmask,
py_fds_to_keep, preexec_fn, preexec_fn_args_tuple);

Expand Down
0