Repository navigation
fix: Windows immediate wait prints the signal-death notice (Refs #3803) - #3811
Merged
Merged
Conversation
Refs #3803 ## 根因 GNU jobs.c:3385 `wait_for` calls `notify_and_cleanup(job)` — the `bash: line 1: PID Killed <cmd>` stderr notice prints inside `wait` as soon as the death is noticed. On Windows the wait's own reap never queued the notice: `wait_for_background_pid`'s poll loop queues it only when `exit_status_signal` returns `Some(signal)`, and that helper is always `None` on Windows (no WTERMSIG). The boundary sweep usually loses the immediate-wait race (its `try_wait` runs microseconds after the kill), so the poll loop does the reap — and it was blind. Hence `sleep 30 & kill -9 %1; wait %1` printed nothing, on base and on the #3799 head alike. The boundary reap already decodes the same death from the flattened status (`apply_job_completion`: `status > 128` -> `status - 128`), which is why delayed-wait checks (with an intervening foreground wait) already printed on Windows. GNU 锚点(bash-5.3,`~/workspace/rubash-audit/build-gnu/bash-5.3/`): - `jobs.c:3064` `wait_for`,`:3385` 调用 `notify_and_cleanup(job)`。 - `jobs.c:3401` `wait_for_job` 标记 `J_NOTIFIED`;`jobs.c:3456` `wait_for_any_job` 扫描未通知死亡作业并 `notify_of_job_status`。 - `jobs.c:3642` `notify_and_cleanup`;`jobs.c:4543` `notify_of_job_status`,`:4625` 起 JDEAD 打印分支。 ## 修复(机制修) 1. `src/executor/wait_status.rs`:新增 `exit_code_signal(status)`—— Windows 上把 128+signal 退出码解码为信号(`code > 128` -> `code - 128`),与边界收割已用的约定完全一致;unix 上恒返回 `None`(内核 wait status 为准)。rubash 自己的 kill 本就按此编码 (`src/builtins/kill.rs` `signal_process` -> `TerminateProcess(128+signal)`)。 2. `src/executor/job_builtins.rs` `wait_for_background_pid` 轮询臂: `exit_status_signal(&done).or_else(|| exit_code_signal(&done))`。 该臂覆盖全部 wait 形态(显式 pid / jobspec / bare wait / procsub 等皆经此函数)。 3. 有意不并入 `exit_status_signal`:其余调用方(jobs 表 `term_signal`、SIGINT-unwind、`#1604 fresh_fatal` 门)在 Windows 上必须继续看到 `None`——否则会悄悄改写 jobs 表渲染 (`Exit 137` -> `Killed`,即另立的 #3802 措辞面)并重排 #1604 的 stash 时序。只修 wait 收割这一面;接受的歧义与边界收割一致 (自然 `exit 137` 读作信号 9,边界收割今天已如此)。 ## 本 PR 删除了什么 无删除。仅新增 `exit_code_signal` 解码函数与 5 格 Windows 回归钉; 无公开 API 变动,无行为删除(Linux 面行为恒等:unix 臂返回 `None`)。 ## 验证(X299 / Windows) - Base(`fcc1de52`)与 head 构建皆 rc=0。 - Fail-first:新钉在 base 上 2/5(3 格即时-wait 全红, `notice missing in: wrc=137`;TERM 控制与顺序格通过);seed 在 base 上 check 1/2/3 皆无通知。 - 修绿:新钉在 head 上 5/5,重跑 5/5;seed 5 格全过,check 1/2/3 皆打印 `... line N: PID Killed sleep 30`,check 4(TERM)正确静默, check 5 通知落在 MARKER1/MARKER2 之间。 - `RUSTFLAGS="-D warnings" cargo check --locked --lib --bins` rc=0; `rustfmt --edition 2021 --check`(3 个改动文件)rc=0。注:`cargo fmt --check` 整仓在 Windows 上报 `os error 206`,在原样 base 树 上亦同,为既存 Windows 环境问题,与本改动无关。 ## 验证(Linux / 新服务器) - `RUSTFLAGS="-D warnings" cargo check --locked --lib --bins` rc=0 (TUNA `--config` 绕行:rsproxy.cn 索引对 os_pipe 404)。 - 邻居钉(`scrubbed_cargo.py`):issue3637 8/8、issue1303(1 ignored)、issue1604 1/1;issue2698 4/5——唯一红格 `wait_jobspec_after_boundary_notice_reports_no_such_job` 在 head 与 base 上皆 3/3 同红(同断言、同 `waitrc=137` 输出),为既存红, 非本 PR 回归。 UNVERIFIED-BY-CAPTAIN
Member
Author
|
【Y3-AUDIT】PR #3811 第1轮 — 建议:PASS 机制核查:
腿:
F 点:无 未跑/VOID 的腿:无 |
Member
Author
|
【Y3-AUDIT】批次汇总(y3 波:#3811 #3810 #3805 #3797 #3795 #3793)
要点:
|
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.
fix: Windows immediate wait prints the signal-death notice (Refs #3803)
Refs #3803
根因
GNU jobs.c:3385
wait_forcallsnotify_and_cleanup(job)— thebash: line 1: PID Killed <cmd>stderr notice prints insidewaitas soon as the death is noticed. On Windows the wait's own reap never
queued the notice:
wait_for_background_pid's poll loop queues itonly when
exit_status_signalreturnsSome(signal), and that helperis always
Noneon Windows (no WTERMSIG). The boundary sweep usuallyloses the immediate-wait race (its
try_waitruns microseconds afterthe kill), so the poll loop does the reap — and it was blind. Hence
sleep 30 & kill -9 %1; wait %1printed nothing, on base and on the#3799 head alike. The boundary reap already decodes the same death
from the flattened status (
apply_job_completion:status > 128->status - 128), which is why delayed-wait checks (with an interveningforeground wait) already printed on Windows.
GNU 锚点(bash-5.3,
~/workspace/rubash-audit/build-gnu/bash-5.3/):jobs.c:3064wait_for,:3385调用notify_and_cleanup(job)。jobs.c:3401wait_for_job标记J_NOTIFIED;jobs.c:3456wait_for_any_job扫描未通知死亡作业并notify_of_job_status。jobs.c:3642notify_and_cleanup;jobs.c:4543notify_of_job_status,:4625起 JDEAD 打印分支。修复(机制修)
src/executor/wait_status.rs:新增exit_code_signal(status)——Windows 上把 128+signal 退出码解码为信号(
code > 128->code - 128),与边界收割已用的约定完全一致;unix 上恒返回None(内核 wait status 为准)。rubash 自己的 kill 本就按此编码(
src/builtins/kill.rssignal_process->TerminateProcess(128+signal))。src/executor/job_builtins.rswait_for_background_pid轮询臂:exit_status_signal(&done).or_else(|| exit_code_signal(&done))。该臂覆盖全部 wait 形态(显式 pid / jobspec / bare wait /
procsub 等皆经此函数)。
exit_status_signal:其余调用方(jobs 表term_signal、SIGINT-unwind、#1604 fresh_fatal门)在 Windows上必须继续看到
None——否则会悄悄改写 jobs 表渲染(
Exit 137->Killed,即另立的 Windows: jobs table renders signal-killed job asExit 137instead ofKilled#3802 措辞面)并重排 [bug] Killed notification intermittently leaks through wait $p 2>/dev/null (residual of #1303) #1604的 stash 时序。只修 wait 收割这一面;接受的歧义与边界收割一致
(自然
exit 137读作信号 9,边界收割今天已如此)。本 PR 删除了什么
无删除。仅新增
exit_code_signal解码函数与 5 格 Windows 回归钉;无公开 API 变动,无行为删除(Linux 面行为恒等:unix 臂返回
None)。验证(X299 / Windows)
fcc1de52)与 head 构建皆 rc=0。notice missing in: wrc=137;TERM 控制与顺序格通过);seed 在base 上 check 1/2/3 皆无通知。
皆打印
... line N: PID Killed sleep 30,check 4(TERM)正确静默,check 5 通知落在 MARKER1/MARKER2 之间。
RUSTFLAGS="-D warnings" cargo check --locked --lib --binsrc=0;rustfmt --edition 2021 --check(3 个改动文件)rc=0。注:cargo fmt --check整仓在 Windows 上报os error 206,在原样 base 树上亦同,为既存 Windows 环境问题,与本改动无关。
验证(Linux / 新服务器)
RUSTFLAGS="-D warnings" cargo check --locked --lib --binsrc=0(TUNA
--config绕行:rsproxy.cn 索引对 os_pipe 404)。scrubbed_cargo.py):issue3637 8/8、issue1303(1ignored)、issue1604 1/1;issue2698 4/5——唯一红格
wait_jobspec_after_boundary_notice_reports_no_such_job在 head与 base 上皆 3/3 同红(同断言、同
waitrc=137输出),为既存红,非本 PR 回归。
UNVERIFIED-BY-CAPTAIN