Skip to content

WIP: #2287 background-pipeline pgrp — no-repro evidence + guard pins (no product change) - #2288

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/issue2287-pipeline-pgrp
Oct 30, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/issue2287-pipeline-pgrp

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

)

Investigation result: the #2287 claim does not reproduce on master.
The issue's grep premise is literally true (pipeline_exec.rs has no
setpgid), but its behavioral conclusion does not follow in rubash's
architecture: a background pipeline's job is the grouped background
wrapper wired by #2251 (spawn_whitelisted new_process_group under
monitor mode), and every pipeline stage is a child of that wrapper
inheriting its group. The recorded pgrp (wrapper pid, `jobs -p`) is
a real, populated kernel group, so hangup_all_jobs' killpg and
`kill -- -<pgrp>` deliver to every stage.

Probed on a master-equivalent build against GNU bash 5.3.20, three
independent paths, same outcomes both shells:
- login route (pty, --login -i): set -m + shopt -s huponexit,
  `sleep N | cat &`, exit -> wrapper and both stages die; without
  huponexit all survive (control).
- script route: set -m, `kill -HUP -- -$(jobs -p)` -> killpg rc=0,
  both stages die.
- /proc membership: stages' pgid == recorded pgrp == wrapper pid.

GNU spec (for the record): jobs.c:2265 make_child — child-side
setpgid(mypid, pipeline_pgrp) at jobs.c:2390, pipeline_pgrp set to
the first child's pid at jobs.c:2372, parent repeats setpgid(pid,
pipeline_pgrp) parent-side (~jobs.c:2455, errors ignored), job pgrp
recorded at jobs.c:649; jobs.c:1783 hangup_all_jobs killpg's
jobs[i]->pgrp; shell.c:1017 is the huponexit exit path. GNU reaches
the observable contract by grouping the shell's direct children;
rubash reaches it through the wrapper group.

No product code changes: grouping pipeline_exec stage spawns per
the GNU in-shell model would move stages OUT of the group that
reaches them today — foreground stages would leave the tty's
foreground group (rubash performs no tcsetpgrp handoff, so
SIGINT/SIGTSTP/SIGTTIN delivery would break), and background stages
would leave the wrapper's group so hangup_all_jobs' killpg(wrapper
pgrp) would miss them, creating the alleged failure.

These pins lock the invariant at the /proc level (membership,
killpg delivery by the recorded pgrp, and a no-monitor control
asserting nothing is grouped without job control) so a future
refactor that detaches stages from the job's group fails here.

Refs #2287
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 30, 2026 23:10
@caomengxuan666
caomengxuan666 merged commit 8e6c0af into master Oct 30, 2026
13 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/issue2287-pipeline-pgrp branch November 2, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant