Skip to content

fix(signals): realtime entries in trap/kill lists + async entry-ignore - #1094

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/signal-table
Oct 23, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/signal-table

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #1036, closes #1035. (1) trap -l/kill -l now cover RTMIN..RTMAX with RTMIN<->41 mapping (GNU signal tables); kill -l 65 still errors. (2) async-job respawns start with SIGINT/SIGQUIT ignored (GNU execute_cmd.c setup_async_signals), consumed from the spawn-site marker before trap-table seeding; trap -p shows the ignore and handlers can't override it. Tests: lib 695 + 11 new regression + RT/kill/trap subsets + fd_redirects green, executor_tests delta-free vs clean tree; GNU parity byte-identical on both issues (one fd_redirects expectation updated to the GNU shape, oracle-confirmed).

…rubash#1036, rubash#1035)

GNU ownership:
- support/signames.c:92-139 initialize_signames (RT arithmetic names
  SIGRTMIN..SIGRTMIN+x / SIGRTMAX-x..SIGRTMAX from the TARGET's
  SIGRTMIN/SIGRTMAX)
- trap.c:236 decode_signal (numeric < NSIG valid, RTMIN+N dynamic forms)
- trap.c:845-852 set_signal ("A signal ignored on entry to the shell
  cannot be trapped or reset, but no error is reported", SIG_HARD_IGNORE)
- trap.c:954-956 restore_default_signal, trap.c:1002-1004 ignore_signal
  (same hard-ignore refusal)
- builtins/trap.def:294-320 showtrap/display_traps (hard-ignored signals
  list as `trap -- '' SIGxxx`)
- execute_cmd.c:5709 setup_async_signals (async children ignore
  SIGINT/SIGQUIT while job_control == 0)
- execute_cmd.c:6126 shell_execve (ENOEXEC -> in-process shell-script
  fallback, never /bin/sh)
- jobs.c background ignore inheritance for `&` children

on the Termux oracle; bash 5.3.20 lists `41) SIGRTMIN`..`64) SIGRTMAX`,
55 entries), not glibc's 34..64 and not empty. The android trap/kill
tables carried no RT names (kill -l 41 silent, RTMIN invalid). Fill both
tables with the signames.c arithmetic split (41..52 RTMIN..RTMIN+11,
53..64 RTMAX-11..RTMAX, 32..40 holes) and pin the base against
`__libc_current_sigrtmin/max` in unit tests. `trap -l`/`kill -l` output
is now byte-identical to the oracle.

`trap ... INT` installed and fired. Model setup_async_signals:
direct-external bg spawns force SIGINT/SIGQUIT to SIG_IGN in pre_exec
when `monitor` is off; wrapper respawns stamp an async marker the child
consumes at startup (before trap seed + ENTRY_IGNORED capture), and
exec-like bodies (bare simple commands GNU would exec) additionally
merge INT/QUIT into the forwarded ORIG_IGN set so the trap is silently
refused and `trap -p` shows `trap -- '' SIGINT`. Compound bodies stay
trappable (trap.c ASYNCSIG special-case), as do `set -m` children.
Also found while reproducing: foreground/background dispatch of scripts
without `#!` went through libc's posix_spawn /bin/sh fallback (no
`trap -p`, wrong traps); such files now take the ENOEXEC shell-script
fallback exactly like GNU (synthetic ENOEXEC into exec_format_refusal;
direct gate declines them to the wrapper).

Verification: repro scripts byte-compared against bash 5.3.20 (script
files): trap -l/kill -l identical; issue parent (bg INT trap) identical
(refused, `trap -- '' SIGINT`, SURVIVED, wait 0); compound-bg handler
still fires; monitor-mode handler fires; parent `trap '' INT`
propagates. cargo test --lib green (695 + 2 new RT tests); new
tests/issue1035_1036_signal_table_regressions.rs green (11);
executor_tests green except 7 pre-existing Termux env failures (also
red on clean tree); issue866 w1 red on clean tree too (android lacks
PR_SET_PDEATHSIG).

Known approximation: `trap - INT` on a never-trapped async INT resets
to ignored rather than POSIX-751 DFL (the reset-request signal is not
tracked); flagged in code review, unobservable in the issue scope.
@caomengxuan666

Copy link
Copy Markdown
Member Author

Rebased onto post-#1181 master and force-pushed as ff2427b3. Conflict note: took master's is_enoexec_candidate gate at the background-spawn site (duplicate of this PR's program_execs_directly check — that function stays, it's still used by the external_inner ENOEXEC synthesis). The rest of the async entry-ignore machinery merged cleanly alongside master's trap/job changes (#1155/#1122). #[cfg(unix)]-gated two new regression tests that exercise kernel signal dispositions — they can't pass on Windows where the feature is inert.

@caomengxuan666
caomengxuan666 merged commit a55e4d6 into master Oct 23, 2026
6 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/signal-table branch October 23, 2026 08:54
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.

[bug] No realtime-signal support in trap -l / kill -l [bug] Signals ignored on entry can be trapped (bash/POSIX refuses)

1 participant