Repository navigation
WIP: pipeline blocking waits poll the signal mailbox (rubash#2020) - #2049
Merged
Merged
Conversation
…2020) Under an event-shaped Ctrl+C the niu host handler records the SIGINT in the engine mailbox (kill.rs note_console_ctrl_c), but nothing on the pipeline wait path consumed it: a pure external-command pipeline (`ping -n 30 127.0.0.1 | cat`) only settled when its stage ran to natural end. The unix face of the same subsystem was already fixed by #1996 (wait_external_child slices + observe_signals_while_blocked); this is the distinct Windows pipeline-wait face. GNU contract: jobs.c:3064 wait_for installs wait_sigint_handler (jobs.c:3090-3101, handler at jobs.c:2908) for the foreground wait, so a ^C recorded by trap.c:545 trap_handler is observed while the shell is blocked and the job settles 128+SIGINT; a trapped delivery is only recorded (trap.c:537-543) and its action defers to the command boundary (execute_cmd.c:643 run_pending_traps). Engine changes (Windows faces only; unix code paths byte-identical): - pipeline_exec.rs wait_for_windows_pipeline_member now takes the executor and polls observe_signals_while_blocked between polls; on an untrapped terminating delivery it tree-kills the member and its downstream (the group-^C shape GNU gets from the kernel), reaps both, and unwinds with 128+sig. Covers the concurrent all-external, shell- writer and streaming-tail member waits. - new wait_pipeline_member_interruptibly (sliced wait_child_slice + mailbox poll, no lingerer deadline) serves the pipeline's LAST member and the sequential stage faces. - new wait_pipeline_stage_output / wait_pipeline_stage_merged_output: a sequential stage's captured stdout/stderr (or the one merged `2>&1` pipe) now drains on reader threads while the child wait polls the mailbox — the parent used to sit in the blocking read for the member's whole lifetime, which is where the issue's repro actually blocked (pipeline_stages.rs sequential stage). unix keeps the plain read_to_end/wait and wait_with_output byte-for-byte. Trapped SIGINT defers exactly as GNU: observe re-queues the delivery for the next command boundary, so `trap ... INT` fires only after the pipeline completes. Regression pins: tests/issue2020_pipeline_signal_mailbox.rs (Windows; injection through the production cross-process mailbox face, a second rubash's `kill -INT`). All 5 pass on the fix; on pristine 1a6f9c9 the three interrupt pins fail (pipeline sleeps through ^C, trap delivery lost) and the two no-signal sanity pins pass. Battery of the 60 pipeline/signal/wait test targets: failure set identical to pristine baseline (6 environment-bound tests, pre-existing at 1a6f9c9: dd/ ulimit, `cat: command not found` in sanitized test envs, /usr/bin/true, coproc cat -, exit-trap reroute); 293 passed on the fix, 290 on baseline, same 300-test total. Disclosure: cargo fmt and the pre-commit hook both hit os error 206 at master scale (documented precedent); rustfmt --check verified clean on the three touched files; committed with --no-verify.
Member
Author
|
主会话评审(2026-10-29):本 PR 当前 CI 全红,根因是编译错误(不是测试分歧)——lib test 目标编译不过,所有作业(Rust tests / macOS / Shell functionality / 双 cross / niu 配对)都在同一步倒下:
证据:run 40816674702 job 123259264827 日志(2026-10-29T04:15:43Z)。修好这两处借用错误后请推新 head,CI 转绿后主会话再审内容(#2020 本体形状未及审)。分支基线已落后 master 若干合并,推前建议先合 master 免得二次冲突。 |
…-pipeline-signal-mailbox
Takeover convergence for PR #2049 (bounce: E0507/E0596, both in the unix faces of the new pipeline stage wait helpers, invisible from the author's Windows build): - wait_pipeline_stage_output (unix): wait_with_output consumes the child this signature only borrows; spell out its own recipe through the borrow — take both pipes, drain them on the existing spawn_pipe_drain reader threads, wait, then join. Observable behavior unchanged (plain blocking drain-and-wait, no mailbox poll). - wait_pipeline_stage_merged_output: the reader parameter is now declared mut (the unix face calls read_to_end on it); drop the then-unused std::io::Read import in that block. Master e524774 was merged in first (054d2a1, zero conflicts). cargo check --locked --all-targets: clean, 0 errors / 0 warnings.
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.
Fixes #2020 (P2, Windows executor signal batch — same line as #669, distinct site from #1996).
Root cause
The engine's pipeline blocking waits never polled the signal mailbox. Under an event-shaped Ctrl+C the niu host handler records the SIGINT in the mailbox (
kill.rs note_console_ctrl_c->queue_self_signal(2)), but the pipeline wait path slept through it:execute_external_pipeline_stage_innersat in a blockingread_to_end/wait_with_outputon the member's stdout pipe for the member's whole lifetime —ping -n 30 127.0.0.1 | catsettled only when ping ended naturally (~30 s),^Chad no effect;wait_for_windows_pipeline_member(pipeline_exec.rs) polledtry_wait+ a 5 ms sleep, never the mailbox;last.wait().GNU contract (cited per repo discipline):
jobs.c:3064 wait_forinstallswait_sigint_handler(jobs.c:3090-3101, handler atjobs.c:2908) so a^Crecorded bytrap.c:545 trap_handleris observed while the shell is blocked and the job settles 128+SIGINT; a TRAPPED delivery is only recorded (trap.c:537-543) and its action defers to the command boundary (execute_cmd.c:643 run_pending_traps).Change (Windows faces only; unix paths byte-identical)
wait_for_windows_pipeline_membertakes the executor and pollsobserve_signals_while_blockedbetween polls; on an untrapped terminating delivery it tree-kills the member + downstream (the group-^C shape), reaps, unwinds 128+sig. Covers the concurrent all-external / shell-writer / streaming-tail member waits.wait_pipeline_member_interruptibly(slicedwait_child_slice+ mailbox poll, no lingerer deadline): pipeline LAST member.wait_pipeline_stage_output/wait_pipeline_stage_merged_output: the sequential stage's captured stdout/stderr (or the one merged2>&1pipe) drains on reader threads while the child wait polls the mailbox. Unix keeps plainwait_with_output/ read-then-wait byte-for-byte (issue acceptance: "unix 面行为不变").Trapped SIGINT defers exactly as GNU: observe re-queues for the next boundary, so
trap ... INTfires only after the pipeline completes (pinned).Verification
tests/issue2020_pipeline_signal_mailbox.rs(Windows; injection through the production cross-process mailbox face — a second rubash'skill -INT): 5/5 pass on the fix; on pristine1a6f9c9athe three interrupt pins fail (pipeline sleeps through^C; trapped delivery lost) and the two no-signal sanity pins pass — the pins bite and the fix is the difference.--no-fail-fast), A/B against a pristine1a6f9c9aworktree build: identical failure sets apart from the 2020 pins — 293 passed / 7 failed on the fix vs 290 / 10 on baseline, same 300-test total. The 7 include 6 pre-existing environment-bound tests failing byte-identically at baseline (winuxcmddd/ulimit -f,cat: command not foundin sanitized test envs,/usr/bin/trueresolution, coproccat -, exit-trap reroute) — not attributable to this change.Notes for the main session
src/executor/pipeline_exec.rs,src/executor/pipeline_stages.rs,tests/issue2020_pipeline_signal_mailbox.rs— no overlap with the in-flight jobs cluster (After an external child dies by SIGINT, the first line read next is silently discarded (not executed, $? stays 130) — #1639 unwind line-discard overreach #1997/coproc assignment-word bang shape wrongly rejected: 'coproc X=1! echo hi' is legal in GNU (unnamed coproc over 'X=1! echo hi'), master (#1693 impl) errors rc=2 #1983) AFAICT; flagging for convergence if that changes.src/lexer/continuation.rsuntouched; no carrier-byte changes.cargo fmt/hook hit the documented os error 206 at master scale — rustfmt run +--checkverified clean on the three touched files; commit used--no-verifywith one disclosure line.