Skip to content

WIP: kill builtin — jobspec walk for retained dead jobs (#2381); posix operand-loop pins (#2382) - #2399

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/kill-builtin-dead-target
Oct 31, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix/kill-builtin-dead-target

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

WIP — kill builtin cluster for #2381 + #2382. Full report:
REPORT.md in ~/workspace/fix-kill-builtin/ (collector copy).

#2381 (commit ba1e90d) — fix

GNU's jobspec arm never signals a 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
signaled in order, the walk stops at the first member whose death
is already recorded (PALIVE, jobs.c:3999-4000), per-member
results never fail the operand. A retained job whose members all
died unwaited succeeds silently, signals and -0 alike.

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_statuses table (the -0 probe) — printing
(pid) - No such process for 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 operands
resolving 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 is
a 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 continue never advances the cursor — a dead head ends
the 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_killing because
config-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) = 0 issued after the
ESRCH — 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

  • Oracle battery (identical script files): settled-dead script
    matches GNU 5.3.20 on every line post-fix; monitor controls
    byte-equal modulo pid.
  • Neighbors (scrubbed runner): issue2344 9/9 · issue2346 11/11 ·
    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 test in this sandbox, three SIGXFSZ pins fail
    because 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/regression branch 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).

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
caomengxuan666 marked this pull request as ready for review October 31, 2026 18:45
@caomengxuan666
caomengxuan666 merged commit f0872a9 into master Oct 31, 2026
11 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/kill-builtin-dead-target 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.

kill builtin: POSIX mode does not stop at the first failed operand

1 participant