Repository navigation
fix(windows): foreground Ctrl+Z stop surface — inject_console_ctrl_z + Windows Stopped arms (Refs #3467) - #3746
Conversation
…+ Windows Stopped arms (Refs #3467) - script_driver::inject_console_ctrl_z() mirrors inject_console_ctrl_c, queueing SIGTSTP (20) on the self-signal queue; kill::note_console_ctrl_z. - wait_external_child (non-unix): untrapped TSTP suspends the child via the Windows signal_process STOP path, parks its handle in background_children, marks the job Stopped(20), prints the stop notice, returns 128+20. - sleep_interruptibly (non-unix): untrapped TSTP materialises a real sleeper child (rubash -c "sleep <remaining>", same exe-resolution chain as the & respawn), suspends it at once and parks it the same way — the virtual sleep's Stopped carrier. fg/bg/wait/kill then work through ordinary real-child machinery; spawn is lazy (only on ^Z). - New tests/issue3467_windows_ctrl_z_stop_regressions.rs: Windows faces (wine) + unix neighbours pinning pre-existing unix semantics. - docs/api-ledger.md: new inject_console_ctrl_z symbol (check-api-ledger passes, 288 symbols). Known gaps (out of scope, see PR body): fg re-stop under the non-unix wait_for_background_pid, pipeline waits, kill -STOP from another session.
|
Note on the red |
|
Thank you for the PR — and for the detailed root-cause write-up and the wine evidence. This is now queued for captain review: per the owner's rule, external PRs are reviewed by the captain first, and I am not merging anything here. CI naming (run 43755493006, canary 43755493010):
One thing the captain has to rule on before this can move — same-issue dual implementation:
What I did not independently verify (left for captain review): the new nail suite's 3/3 wine + 2/2 unix results are your local claim — CI's nextest table has no new-nail stem, so CI green/red here is not evidence the new suite ran; no Windows real-machine run; GNU-oracle fit for the materialisation carrier; and this PR touches Small hygiene ask: please add one line to the body — a "Deleted: none" section (the repo convention asks every PR body to state what it deleted, even when the answer is nothing). |
|
【WIN-AGENT-AUDIT】PR #3746 第2轮 — 建议:PENDING(缺腿已补;队长排序裁决不变) 队长裁决维持:先行链 = #3538 → #3567,本 PR「停时物化」载体暂缓、不关闭、不并行合入。本轮补跑第1轮缺的腿,不改判词。 腿(逐项数字与名字):
F 点:无新增(机制层面与 #3538→#3567 的载体冲突已由队长裁决覆盖) 续作记录:无(未动代码、未 push) 未跑/VOID 的腿:
|
Root cause
niubash#877 (Windows foreground Ctrl+Z) was ruled not implementable on the
niubash side alone: the engine had no surface to stop a foreground job.
script_driverhad onlyinject_console_ctrl_c()(hard-wired signal 2);queuing 20 (SIGTSTP) into the mailbox was worse than a no-op — the Windows
foreground wait unwound it as a termsig (exit 128+20 = 148), the non-unix
wait_external_childkilled the child,jobsshowed nothing,fghadnothing to resume. All Stopped arms were unix-only.
What changed (companion spec, engine half)
script_driver::inject_console_ctrl_z(), mirroringinject_console_ctrl_c, queueing 20 on the self-signal queue(
kill::note_console_ctrl_z(); unix is a no-op). Ledger updated(
docs/api-ledger.md,check-api-ledger.pypasses, 288 symbols).wait_external_child: untrapped TSTP suspends the child via theWindows
signal_processSTOP path, parks a duplicated handle inbackground_children,job_table.mark_stopped(pid, Some(20)),prints
format_stopped_job_notice, returns 128+20.sleep_interruptibly: same, for the virtual sleep (see carrier).A stop is neither a death nor a discard: both arms clear the death
record + discard mark
observe_signals_while_blockedattached, andthe list continues after the stop (verified against bash 5.2:
sleep 5; echo CONTINUED+^Zprints the notice and still runs CONTINUED).Trapped TSTP still runs the trap and does not stop (pinned by test).
Carrier decision: stop-time materialisation
The virtual sleep has no pid, and
mark_stoppedneeds a job entry. Onuntrapped TSTP the arm spawns this binary as a real sleeper child
(
rubash -c "sleep <remaining>", same exe-resolution chain as the&respawn), suspends it at once, and parks it as the stopped job.
fg/bg/wait/killthen work through ordinary real-child machinery;the spawn is lazy (only on ^Z). Rejected: synthetic pid + Executor
sidecar (leaves
bga phantom Running job andwaitbroken); makingWindows sleep a real child (dispatch-semantics change); notice-only
(fails acceptance); defer.
Verification (Simular box, cross-compiled + wine)
tests/issue3467_windows_ctrl_z_stop_regressions.rs, Windows facesunder wine: 3/3 pass — virtual sleep ^Z stops the job (148, notice,
jobslists it) andfgresumes it to 0; real-child ^Z, same; trappedTSTP runs the trap, no stop. Unix faces: 2/2 pass (plain sleep
completes; a queued TSTP leaves a real-child sleep undisturbed — since
[ecosuite] bats timeout.bats #2/#3: timed-out test's process tree/pipe not reaped, outer run takes full 10s #3488 unix sleep is a real child whose blocking waitpid never observes
a mailbox TSTP, 引擎等待面:前台命令执行期终止信号只在命令结束边界被消费,GNU 在等待中即信号死(niu #988 时序残差归宿) #3284).
cargo test --lib: 1248 passed; the one failure(
issue2875_input_procsub) was a missing-binary precondition of running--libalone and passes on retest with the bin built.0a405d8aon the same box, identical transcripts): job control: foreground child SIGTSTP stop is invisible to the shell (no WUNTRACED/tcsetpgrp in interactive wait path) #2398 test 2(
wait %1afterkill -9→no such job, W=127) and the fix(executor): real uid/euid identity instead of root emulation #698"forgotten SIGINT" tests (130) are box-load PTY/mailbox timing flakes.
cargo fmt --check,git diff --checkclean. Unix semantics untouched(only
let _ =+cfg(not(unix))arms on the unix paths); ruline pin,quotes/alias, termsig, Session dual driver untouched.
the new suite may not actually run in CI — the box/wine evidence above
is the authority for it.
Known gaps (out of scope)
fg(non-unixwait_for_background_pidhas no stoparm): the child keeps running, the job stays Running.
kill -STOP <fg-pid>from another session (shell would hang waiting —pre-existing).
Only opening the PR, not merging — niubash side follows after this lands.