Repository navigation
fix: signal trap coverage for all trappable signals (#1511) + part_036 job-notification visibility - #1527
Merged
Conversation
…511) The kernel-signal backend managed dispositions for only seven signals (HUP/INT/QUIT/TERM/USR1/USR2/PIPE) plus the SIGSEGV/SIGBUS fatal pair. A trap on any other signal changed nothing at the kernel: trapped terminating signals (ILL TRAP ABRT FPE ALRM STKFLT XCPU XFSZ VTALRM PROF IO PWR SYS RTMIN..RTMAX) still killed the shell by their default action with the handler never running, trap '' SIG never installed SIG_IGN, and trapped URG/WINCH were never delivered. A 30-signal trap storm died at SIGILL. - Extend the managed set to every trappable signal the trap table can name: the named signals plus the POSIX realtime block (libc SIGRTMIN()..=SIGRTMAX() on linux/android). Disposition state widens to two packed words; the trap-key table and the boundary reconcile are built once at runtime. The reconcile fast path now detects armed traps with one __RUBASH_TRAP_SIG prefix pass instead of probing a fixed key list. - SIGILL/SIGFPE cannot ride the signal_hook backend (its registry panics: "Attempted to register forbidden signal"), so they join the fatal set (SIGSEGV/SIGBUS) whose sigaction handler splits SENT deliveries (shell semantics) from hardware faults (chain). - EXIT-trap reroute (sig.c:226-229) applies to the managed set except the default-ignore pair and the realtime block, which GNU's compile-time terminating set cannot name (oracle-verified); SIGILL/SIGFPE reroute through the fatal mapping, SIGSEGV/SIGBUS keep their existing no-reroute rule. Oracle matrix (GNU bash 5.3.20): 30 signals x trapped/untrapped/ ignored forms all match, the 30-signal storm completes with every handler run, EXIT-reroute probes match. SIGCHLD (owned by the reap dispatcher) and the stop class stay unregistered by design. Regression tests: tests/signal_trap_coverage_regressions.rs (issue_1511_* — trapped/ignored/untrapped/reset forms, EXIT reroute and its exclusions, the storm).
…_036) Regression from the fourth slice (PR #1509): the per-command boundary reap applied a background job's completion to the job table the moment try_wait returned it, so in a single read (-c / in-process list) `jobs` after a jobspec kill already listed the job as Terminated. GNU bash 5.3.20 lists it as Running there: waitchld state becomes visible only at observation points — the reader pulling a new line, a blocking wait_for (which reaps background children while it blocks, jobs.c:3064), or an explicit wait/fg. Script-file form was unaffected (each line is its own read) and still shows Terminated. - refresh_background_jobs now stashes reap results for non-coproc jobs in pending_job_completions and applies them when the observation mark (execute_ast generation, reader command line, foreground wait count) has advanced since the previous refresh, or immediately when the refresh itself observes (wait/fg form, refresh_background_jobs_observed). Coproc disposal keeps its per-command contract (rubash#1023); capture-writer retirement and forwarder joins stay immediate (I/O hygiene, not table visibility). - Foreground waits note the observation counter: the unix wait in wait_external_child, pipeline tail/stage waits (wait and wait_with_output forms), and the native sleep fast path — GNU sleep is a real child whose wait_for is an observation point, and rubash's in-process sleep emulates it (the part_036 suite itself uses `sleep 0.3` as the observation delay). executor_tests part_036: 33/33 (baseline 32/33, the titled test failing); part_035 stays 21/21; the remaining segment failures match the baseline set name-for-name (modulo glob/cwd-sensitive flakes). The titled test itself is the regression test — it already asserted the GNU behavior and now passes unmodified.
This was referenced Oct 25, 2026
Merged
caomengxuan666
added a commit
that referenced
this pull request
Oct 25, 2026
…e debugger design (#497) (#1535) Both designs were approved as written by the owner on 2026-10-25 and are finalized together as one 1.5.0 implementation program (split and debugger interleaved, module by module). - 1.5.0-session-api.md extends docs/design/1.5.0-workspace-and-engine-api.md (the #595 RFC): section 11 Q1-Q8 are decided per the recommendations recorded there, with a decision record in section 12. Q4: the syntax surface is tier-B api::syntax view types; the internal Ast is not frozen into tier A. Q5: the threading contract is explicitly single-threaded, one Session per thread. - debugger-full-design.md extends docs/design/debugger-m0.md (the #497 M0 draft of record) and does not supersede it: section 14 Q1-Q5 are decided per the recommendations recorded there (Q1 stop at first command; Q2 session core built in-tree now, shaped for rubash-core; Q3 conditions stay full shell commands; Q4 trace via the xtrace fd machinery; Q5 engine-level injectable command stream), with the finalization recorded in section 15. Prerequisites P-1 (#1184 f4, PR #1522) and P-2 (#1511, PR #1527) are marked landed. Docs only; no code changes. Co-authored-by: 曹梦轩 <[email protected]>
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.
Summary
Fourth-wave slice: signal trap coverage (#1511) + the part_036 in-process job-notification regression (no standalone issue; tracked since the slice-4 integration report). Two commits cherry-picked from the sig cluster branch onto current master, zero conflicts, patches identical to the cluster originals.
Fixes #1511
1. #1511 — traps on non-hosted signals never reached the kernel
Root cause. The
kernel_signalsbackend insrc/builtins/kill.rsmanaged kernel dispositions for only seven signals (HUP/INT/QUIT/TERM/USR1/USR2/PIPE) plus the SIGSEGV/SIGBUS fatal pair. A trap on any other signal was recorded in the trap table, but reconcile never installed a handler or SIG_IGN at the kernel:trap '' SIGnever became a real SIG_IGN;(The brief's older note that untrapped
kill -SEGV $$survived with rc=0 was already fixed by #1475 in slice 4 — re-measured on current master: untrapped SEGV/BUS die 139/135. Not re-fixed here.)Fix (all in
src/builtins/kill.rs).SIGRTMIN()..=SIGRTMAX()on linux/android; no RT block on Darwin/BSD, matching GNU signames.c). SIGCHLD (owned by the reap dispatcher) and the stop signals TSTP/TTIN/TTOU stay unregistered by existing design.Verification vs GNU bash 5.3.20. Per-signal matrix, 30 signals × 3 forms (trapped / untrapped / ignored): all OK. 30-signal storm byte-identical to GNU (rc=0, all 30 handlers run). EXIT-reroute probes (ALRM / URG / WINCH / XCPU + ILL/FPE spot checks) all match. Regression tests:
tests/signal_trap_coverage_regressions.rs, 7issue_1511_*tests with GNU expectations, in the same commit.2. part_036 — background job completion became visible too early
Root cause. Regression introduced by slice 4 (PR #1509), recorded in its integration report. The per-command boundary reap applied a background job's completion to the job table the moment
try_waitreturned it. GNU's waitchld state becomes visible only at observation points: the reader pulling a new line, a blockingwait_for(which reaps background children while it blocks, jobs.c:3064), or an explicitwait/fg. In a single read (-c/ in-process list),killfollowed only by builtins has no observation point, so GNU still lists the job as Running; rubash listed Terminated (test_kill_jobspec_keeps_job_listed_until_reapfailed; script-file form was unaffected because each line is its own read).Fix (executor layer, main logic in
src/executor/job_builtins.rs). Reap results for non-coproc jobs are stashed inpending_job_completionsand applied when the observation mark (execute_ast generation, current reader line, foreground wait count) has advanced since the last refresh, or immediately atwait/fgentry points. Foreground wait count is wired intowait_external_child, pipeline tail/stage waits, and the native sleep fast path (GNU's sleep is a real child whose wait_for is an observation point; rubash's in-process sleep simulates one). Coproc disposal keeps its per-command contract (#1023); capture-writer retirement and forwarder joins stay immediate (I/O hygiene, not table visibility).Verification. Four binary spot-check forms match GNU exactly (
-ckill/printf/jobs/wait → Running + after:0; script file → Terminated; kill+sleep+jobs → Terminated; natural death + sleep → Done; after foreground pipeline wait → Done). executor_tests segmented run: part_036 33/33 (baseline 32/33, the failing test now passes unmodified), part_035 21/21.Slice verification (integration tree)
cargo build --locked: PASStests/signal_trap_coverage_regressions.rs: in the gated pipeline run the storm test failed once under machine load (6/7); adjudicated in isolation on the same tree — storm test 3/3, full target 7/7 twice. The test fires 24 signals and is timing-sensitive under contention; the cluster tree also passed 7/7.cargo test --lib: 728 passed / 1 failed — the only failure isownership_unary_operators_check_existing_file, the known root-environment itemKnown residuals (as-is, recorded in the cluster report)
trap ''is handler-discard rather than a kernel SIG_IGN ([bug] SIGSEGV sent to the shell itself is swallowed (kill -SEGV $$ has no effect) #1475's existing trade-off, now inherited by ILL/FPE): after a realexecreplacement, caught signals reset to SIG_DFL per kernel rules, whereas GNU's true SIG_IGN survives exec. Forked subshell paths are covered by the existing restore mechanism.readalso make waitchld state visible in GNU but are not counted as observation points here (no suite form exercises it; baseline behavior not worsened). REPL lines are covered via the execute_ast generation.