Repository navigation
WIP: signal-death residuals — EXIT trap entry status (#2352) + ancestor-lane SIG_DFL death (#2353) - #2371
Merged
Conversation
…eath GNU: sig.c:590 termsig_handler() calls run_exit_trap() (sig.c:644) then kill_shell(sig) (sig.c:646); nothing on that path rewrites last_command_exit_value to 128+sig — trap.c:1036 run_exit_trap saves last_command_exit_value as the trap's entry $?. The 128+sig synthesis belongs to child wait-status translation only (jobs.c:2961). Captured at both death-mark points (boundary note + hangup drain classification) BEFORE the 128+sig overwrite: at a boundary the value is the last completed command's status; at a blocked-wait drain it is likewise the last completed command (the interrupted wait never commits). The ancestor lane delivers after its carrier construct committed, so the parent's pre-carrier value is snapshotted at queue time instead: execute_kill arms the status it started with (the kill builtin completes before dispatch, so its own 0 is the value for direct deliveries) and queue_ancestor_signal stamps it on the entry; the dispatch overrides the capture with the sender snapshot for ancestor entries. finish_shell consumes the capture together with the death mark and runs the EXIT trap with it. The capture parks and restores with the mark across contained-child spans (external_finish), matching the #2346 discipline. Refs #2352
…IT trap A #1654 routed delivery is synthetic — no kernel disposition ever fires for it — so the boundary dispatch enacts the addressed shell's verdict itself. GNU's matrix for the untrapped cell: with no EXIT trap in a non-interactive shell, initialize_terminating_signals never installs a terminating handler (sig.c:230-236 — it runs for non-interactive shells only when an EXIT trap is defined), so the delivery stays at SIG_DFL and the shell dies BY the signal. note_routed_untrapped_termsig arms the same termsig-death mark for that cell (signal in the exit_reroutes terminating set, non-interactive, no contained-child route — a contained child's death is the simulated adjudicated record, rubash#2236). SIGINT is the exception and is absorbed, not armed: while a script shell waits for a foreground job, wait_sigint_handler (jobs.c:2908) records the delivery and otherwise ignores it; the shell dies of SIGINT only when the job itself died of it (jobs.c:4384, 4410 child_caught_sigint). The lane's carrier completed normally by construction — the entry surfaces only after the carrier exits — so the dispatch drops the entry and the carrier's status stands. Kernel-lane entries are untouched (their stale check proves a handler story this lane never has), as are interactive shells (DISCARD classification, rubash#1662). Refs #2353
caomengxuan666
marked this pull request as ready for review
October 31, 2026 16:02
This was referenced Oct 31, 2026
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.
Refs #2352
Refs #2353
Audit-wave residuals from PR #2351, two commits, GNU bash 5.3 source-first (clean-room: behavior facts only).
#2352 — EXIT trap entry
$?on signal death (commit e4d1666)GNU:
sig.c:590 termsig_handler→run_exit_trap()(sig.c:644) →kill_shell(sig)(sig.c:646); nothing rewriteslast_command_exit_valueto 128+sig —trap.c:1036saves it as the trap's entry$?. 128+sig is child wait-status translation only (jobs.c:2961).execute_killarms the status it started with (the kill builtin completes before dispatch; direct deliveries therefore capture its own 0),queue_ancestor_signalstamps it on the entry, and the dispatch overrides the capture for ancestor entries.finish_shellconsumes the capture with the mark; the capture parks/restores across contained-child spans with the mark ([bug] 致命信号死亡形态:EXIT trap 照跑,但以 128+n 退出而非被信号杀死 TERM/INT/USR1(审计 RC3) #2346 discipline).#2353 — ancestor lane, no EXIT trap, non-interactive (commit 96113da)
sig.c:230-236), so an untrapped fatal delivery stays SIG_DFL and the shell dies by the signal. The lane is synthetic (no kernel disposition fires), sonote_routed_untrapped_termsigarms the same termsig-death mark for exactly that cell (terminating set, non-interactive, no contained-child route — 嵌套 rubash 子进程以未捕获信号自杀时外层跟着同信号死(GNU 报 143 并继续) #2236's simulated death untouched; kernel-lane entries untouched — their stale check proves a handler story; interactive DISCARD untouched — [P0][release-gap] Ctrl-C still kills interactive shell on latest release 1.4.4 (master fix #1414 unshipped) #1662).jobs.c:2908 wait_sigint_handlerrecords and otherwise ignores an untrapped SIGINT while waiting; death follows only when the job itself died of SIGINT (jobs.c:4384/4410). The carrier completed normally by construction, so the dispatch drops the entry.Verification
waitpid-adjudicated — shell$?cannot distinguish signaled death from 128+n) against GNU bash 5.3.20: 31/32 byte-exact. The one non-exact cell (ancestor SIGINT + EXIT trap) is racy in GNU itself across identical runs (signaled 2 twice, SURVIVED once — arrival before vs during the parent's wait); rubash deterministically takes the termsig outcome, consistent with [bug] 致命信号死亡形态:EXIT trap 照跑,但以 128+n 退出而非被信号杀死 TERM/INT/USR1(审计 RC3) #2346. The no-trap ancestor SIGINT cell takes the documented wait-absorb outcome (jobs.c:2908; GNU majority in sampling). Both races are recorded in the cluster report, not papered over.issue2352_exit_trap_status_regressions8/8,issue2353_ancestor_lane_termsig_regressions13/13.cargo checkclean, 0 warnings; touched files rustfmt-clean;src/lexer/continuation.rsNOT touched.Known residual boundary
Ancestor snapshot layer corner: if the sending layer runs status-changing commands before its
kill(e.g.(exit 7)then( false; kill -TERM $$ )), the snapshot is the layer's last-completed status where GNU's preempted parent keeps the pre-outermost-carrier one (the layer's commands run in a child). Exact capture needs a layer-entry snapshot hook the layer machinery does not have; the bare-carrier shapes the issues mandate are exact. Recorded in the cluster report.