Repository navigation
WIP: kill builtin — jobspec walk for retained dead jobs (#2381); posix operand-loop pins (#2382) - #2399
Merged
Conversation
Refs #2381 GNU's jobspec arm does not signal one representative pid: builtins/kill.def:226-262 resolves the spec to a job and jobs.c:3961-4007 kill_pid walks its pipeline — live members are signaled in order, the walk stops at the first member whose death is already recorded (jobs.c:3999-4000, PALIVE), and per-member results never fail the operand. A retained job whose members all died unwaited therefore succeeds silently, for real signals and for -0 alike. The tracked kill loop collapsed the spec to the job's last pid and judged that pid by raw kill(2) (delivery) and by the completed_statuses table (the -0 probe), printing "(pid) - No such process" for exactly that retained dead job. Jobspec operands resolving to a retained non-job-control job are now walked over the entry's members: recorded-dead members stop the walk (a member dying mid-walk is passed over the same way), live members are delivered with the existing bookkeeping (note_fatal_signal / monitor deferred marks, factored unchanged into note_kill_delivery), and an all-dead job is a silent success. Pid-form operands keep the plain kill(2) verdict (jobs.c:4023) — in the settled state GNU ESRCHs them on a retained job too. Job-control jobs keep the existing killpg-arm path. Pins: tests/issue2381_kill_dead_job_regressions.rs (7).
Refs #2382 The filed premise — posix mode stops the kill operand loop at the first failure — is falsified by the GNU source: builtins/kill.def:81-85 maps CONTINUE_OR_FAIL to goto continue_killing because config-top.h:21-24 defines CONTINUE_AFTER_KILL_ERROR ("This is what POSIX.2 specifies"); posix changes only the final tally (kill.def:283-286). Verified against the 5.3.20 oracle by strace in all three posix entry modes: after kill(999999) = ESRCH the oracle still issues kill(<live>, SIGTERM) = 0. The "surviving target" reading came from probing liveness with kill -0, which answers success for an unreaped zombie. Rubash already implements the true contract, so there is no product change; these pins assert GNU's behavior (operand processing continues in both modes; aliveness judged by wait status behind a watchdog, never kill -0) so the falsified semantics cannot be introduced later as a "fix". Pins: tests/issue2382_kill_posix_operand_regressions.rs (5).
caomengxuan666
marked this pull request as ready for review
October 31, 2026 18:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP — kill builtin cluster for #2381 + #2382. Full report:
REPORT.mdin~/workspace/fix-kill-builtin/(collector copy).#2381 (commit ba1e90d) — fix
GNU's jobspec arm never signals a representative pid:
builtins/kill.def:226-262resolves the spec to a job andjobs.c:3961-4007 kill_pidwalks its pipeline — live memberssignaled in order, the walk stops at the first member whose death
is already recorded (
PALIVE, jobs.c:3999-4000), per-memberresults never fail the operand. A retained job whose members all
died unwaited succeeds silently, signals and
-0alike.Root cause: the tracked kill loop collapsed the spec to the job's
last pid and judged it by raw kill(2) (delivery) and by the
completed_statusestable (the-0probe) — printing(pid) - No such processfor exactly that retained dead job.The jobspec path never consulted the retained job entry, which is
GNU's whole verdict for that arm.
Fix (in
execute_tracked_background_kill): jobspec operandsresolving to a retained non-job-control job are walked over the
entry's members; recorded-dead members stop the walk (mid-walk
deaths pass over the same way); live members get the existing
delivery + bookkeeping (
note_fatal_signal/ monitor marks,factored unchanged into
note_kill_delivery); an all-dead job isa silent success. Pid-form operands keep the plain kill(2)
verdict (jobs.c:4023 — GNU ESRCHs them on a retained job in the
settled state too; the rc=0 readings live only in GNU's racy
unreaped window, which kill(2) already reproduces). Job-control
jobs keep the existing killpg-arm path (verified byte-equal:
dead jc job rc=1 ESRCH, live jc pipeline rc=0 on both shells).
GNU walk quirks bounded by experiment (oracle + strace): the
PALIVE
continuenever advances the cursor — a dead head endsthe walk (verified) and a dead later member makes GNU spin
forever (verified twice; the hang is not cloned — the delivery
set, the live prefix, is).
Model note: rubash realizes background pipelines behind one
supervisor member (stage pids are grandchildren), so pipeline
walks have a single member whose delivery ends the pipeline —
GNU's end state in the all-live and dead-tail shapes. GNU's
dead-head quirk has no rubash counterpart (no per-stage death
records exist in the shell); predates this change.
Pins:
tests/issue2381_kill_dead_job_regressions.rs— 7/7.#2382 (commit 2562fc6) — premise falsified, pins only
The filed claim (posix mode stops the operand loop at the first
failure) is contradicted by the source: kill.def:81-85 maps
CONTINUE_OR_FAIL to
goto continue_killingbecauseconfig-top.h:21-24 defines CONTINUE_AFTER_KILL_ERROR ("This is
what POSIX.2 specifies"); posix changes only the tally
(kill.def:283-286). Strace of the oracle in all three posix
entry modes shows
kill(<live>, SIGTERM) = 0issued after theESRCH — the target dies in every mode. The "survives" reading is
the kill -0-on-a-zombie trap. Rubash already implements the true
contract; no product change (implementing the claim would have
created the divergence). Pins assert GNU's real behavior,
aliveness judged by wait status behind a watchdog, never
kill -0:tests/issue2382_kill_posix_operand_regressions.rs— 5/5. Recommendation: close #2382 as not-a-bug with this
evidence.
Verification
matches GNU 5.3.20 on every line post-fix; monitor controls
byte-equal modulo pid.
issue2348_2347 19/19 · issue2241 5/5 · issue1035_1036 9/9 ·
issue1990_1991 5/5 (one load-flake rerun) · issue1043_1054 6/6
and signal_trap_coverage 7/7 via the compiled binaries directly
(under
cargo testin this sandbox, three SIGXFSZ pins failbecause the cargo chain runs test children with SIGXFSZ
ignored — entry-ignored signals can neither be trapped nor
hidden from
trap -p; launcher artifact, unrelated).tests/regressionbranch vs master, identical conditions:217/11 vs 218/10; master's reds ⊂ branch's; the one branch-only
red (issue2056 drains-pipes) is a 30 s harness-throughput
timeout whose hot loop never invokes the changed code
(master standalone 3/3 at load ~2; branch timeout at load 9).