Repository navigation
fix(executor): classify a wait-time shell-only SIGINT by the child's outcome (Refs #2729) - #3695
Merged
Merged
Conversation
…outcome (Refs #2729) GNU wait_for installs wait_sigint_handler for every non-job-controlled foreground wait (jobs.c:3088-3102): the handler only records (wait_sigint_received), and waitchld classifies by the job's outcome — jobs.c:4157-4158 sets child_caught_sigint when the job exited normally or died by another signal, jobs.c:4162-4163 clears it only when the job died by SIGINT. The 4410ff cleanup acts on the recorded delivery (trap / termsig_handler re-raise) only when child_caught_sigint == 0. The wait drained the mailbox through the plain observe path, so an untrapped shell-only SIGINT adjudicated as a 128+SIGINT death whatever the child did. Add the recording arm: the guard's script mode swaps an untrapped SIG_DFL to the mailbox handler for the wait's span (a trapped SIGINT is already mailbox-routed; an ignored one stays ignored, jobs.c:3100-3101), the recording wait swallows queued SIGINTs into wait_sigint_received through observe's new sink, and the tail re-raises via termsig_death_pending only when the child died by SIGINT — trapped, the pending trap is re-queued for the boundary.
This was referenced Nov 15, 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.
【WIN-AGENT-FIX】
Problem
A
kill(2)SIGINT delivered to a non-interactive script shell while it waits on a foreground child killed the shell mid-wait as a real signal death — whatever the child did. Pinissue2729_shell_only_sigint_wait: cells A (child exits normally → shell must survive,AFTER rc=0) and B (child dies by SIGTERM → shell survives,AFTER rc=143+Terminatednotice) were red; the group-SIGINT control (shell dies by SIGINT) was already green.Root cause
GNU
wait_forinstallswait_sigint_handlerfor every non-job-controlled foreground wait (jobs.c:3088-3102) — it only recordswait_sigint_received.waitchldthen classifies by the job's outcome (jobs.c:4157-4163child_caught_sigint), and the4410ffcleanup re-raises / runs the trap only when the job itself died by SIGINT. Rubash's unarmed wait drained the mailbox through the plainobserve_signals_while_blockedpath — an untrapped SIGINT adjudicated to a 128+SIGINT death regardless of the child's end (or died by the kernel disposition outright).Fix
ForegroundWaitSigintGuard::hold_for_script_wait: non-interactive arm of the same hold — untrapped SIG_DFL swaps to the mailbox handler for the wait's span; trapped SIGINT is already mailbox-routed (record-only, no hold); SIG_IGN stays unarmed (GNU restores it,jobs.c:3100-3101).heldtracks who installed the routing so Drop releases only real holds.observe_signals_while_blocked_recording_sigint: observe variant swallowing every queued SIGINT (trapped or not) intowait_sigint_received— GNU's handler records, never dispatches mid-wait.wait_fg_child_recording: the record-only drain + tail drain before return (the handler stays installed until the wait ends).wait_external_childtail classification: recorded SIGINT acts only when the child died by SIGINT — untrapped →termsig_death_pending(EXIT trap thendie_by_signal, GNUtermsig_handler/kill_shell); trapped → re-queued for the boundary. Otherwise discarded.Legs
issue2729_shell_only_sigint_wait: 2 red → 3/3 greenAFTER rc=0, exit 0) and child-SIGTERM (Terminatednotice +AFTER rc=143, exit 0)issue698unix_faces 2 reds reproduce on pristine master (pre-existing, unrelated)RUSTFLAGS="-D warnings" cargo build --lockedclean;cargo fmt --checkclean on touched files