Skip to content

fix(jobs): stamp death notices at the reader line, print fg deaths at the wait (Refs #2769) - #3480

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/2769-job-notice-line-stamp
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/2769-job-notice-line-stamp

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

摘要

jobs 边界死亡通知的行戳问题(#2769):GNU 以打印时刻的全局 line_number 盖戳(jobs.c:4641)——后台死亡在读者边界打印时已读到下一行(parse.y:2533),前台死亡在 wait_for 内同步通知(jobs.c:3385),戳为垂死命令本行。rubash 把两面都排队到读者边界、盖刚结束命令的行戳,且流末 sweep 发现的 completion 被 stash 后再无机会应用,EOF 通知直接丢失。

修法(三文件,同一机制:eager recording):refresh_background_jobs_impl 的观察门收窄为单一谓词(force_observe / foreground_blocked / monitor+tty),裸 reader 前进不再应用 completion;stash 的 completion 带首次发现 instant,5 ms SIGCHLD 投递老化后应用;jobs 只应用 coproc completion;新增 print_fg_signal_notice_now,前台死亡在 wait 处同步打印、盖 ambient 行。

回归钉:tests/issue2769_death_notice_line_stamp_regressions.rs(master 已有,5 格;基底 3 红、头 5 绿)。

Refs #2769

本 PR 删除了什么

无文件/符号删除。3 文件 +170/−56:观察谓词收窄、stashed completion 由三元组改为带 instant 的四元组、5 处 note_child_signal_death 调用点改为 print_fg_signal_notice_now(函数本身仍有其他调用点,未删除)。未删除任何公开 API。

验证状态

  • 本地:cargo fmt --check 通过;钉 head 5/5、base 3 红 2 绿(fail-first 逐名);10x e1/e5 矩阵;GNU oracle 三方对照。
  • CI 待跑;全腿待队长复核轮。
  • UNVERIFIED-BY-CAPTAIN:尚未经队长复核。

…hs at the wait (Refs #2769)

GNU's notify_of_job_status stamps a background death with the global
line_number at the moment the notice prints (jobs.c:4641) — by then the
reader has advanced to the next line (parse.y:2533) — while a
foreground death is notified synchronously inside wait_for (jobs.c:3385)
and stamped with the dying command's own line. rubash queued both
faces for the reader boundary and stamped the just-finished command's
line, losing the EOF notice outright when the sweep's completion was
stashed at stream end.

- refresh_background_jobs_impl: the observation gate is now the single
  narrow predicate (force_observe / foreground_blocked / monitor+tty);
  a bare reader advance no longer applies completions.
- Stashed completions carry their first-seen instant; they apply once
  the 5 ms SIGCHLD-delivery aging has elapsed (same constant as the
  state-mark rule).
- execute_jobs applies only coproc completions; `jobs` records no new
  background death.
- New print_fg_signal_notice_now: fg deaths print synchronously at the
  wait through the shared emit core, stamped with the ambient line.

Regression pin: tests/issue2769_death_notice_line_stamp_regressions.rs
(pre-existing on master, 5 cells; 3 fail on base, 5 pass on head).

Refs #2769
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】

PR #3480 第1轮 — 建议:PENDING(缺腿)
head: f1ff5eb base(merge-base): e50cea9 文件: 3 个 +170/-56
关联 issue: #2769(状态:open,我核过的时间:本地当前;本 PR 无先验评论)

机制核查:

腿(逐项):

  • 钉自跑:issue2769_death_notice_line_stamp_regressions(既有 5 格钉,base 上已存在)head → 3 passed / 2 failed。2 红 = fg_notice_stamps_the_dying_commands_own_line 与 subshell_member_notice_stamps_the_compound_end_line,均依赖 SIGXFSZ(ulimit -f 1+dd),Windows 无 ulimit-f 强约束与真信号死亡 → 环境绑定红。3 格边界面钉(bg/next-line/EOF)全绿。
  • fail-first:base e50cea9 同 stem → 同样 3/5,红集完全相同 → Windows 本腿对修复面无区分力(SIGXFSZ 面两侧同红);Linux 侧未跑(CI 被 issue2875 fail-fast 截停)。
  • 补验 Windows 可观测度:./rubash.exe -c 'kill -KILL $$' 前台子进程 → rc=137 但无通知(Windows 子进程非真信号死,wait_status 无 signal 位);GNU 同形(bash -c 'kill -KILL $$')印 line 2: PID Killed 在 wait 处同步——fg 面整个不可在 Windows 观测。
  • lib 双边:head 失败名集 {issue2084_session_end_restores_host_process_state} / base 同集 / 差集 ∅。
  • -D warnings:lib check 干净 0 警告。
  • 卫生:rustfmt --check 三文件 FMT-OK;marker-lint OK(117 consts);utf8-boundary clean。
  • CI:红任务归因——Rust tests / macOS / GNU goldens 均为已知基线 issue2875(日志实证 consumer_tests.rs:2911 Unrecognized option: 'c',nextest 24/1246 fail-fast → issue2769 stem 在 Linux 未跑到);其余全绿。
  • GNU 对照:WSL GNU bash 5.3.20(1)。6 形状全验证:g1 sleep 5 & kill -KILL %1; sleep 0.3; jobs → line 4: Killed;g2 interposed true → line 4;g3 EOF → line 4(末行+1);g4 复合成员 dd 死 → line 6(复合收尾行)且印于 inner 前;g5 前台 dd 死 → line 2(自身行)印于 rc= 前、rc=153;g6 echo x 边界 → line 4 印于 x 前、jobs 已退休。脚本:target/probes-3480/{g1..g7}.sh。

F 点:无。

续作记录:未动代码。

未跑/VOID 的腿:

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-REWORK】

PR #3480 第2轮 — 建议:PASS(缺腿补齐)
head: f1ff5eb(与审计一致,无人推进) base(merge-base): e50cea9
关联 issue: #2769

本轮补腿(WSL Linux /root/rubash-wsl,CARGO_INCREMENTAL=0,cargo test --locked -j 2):

  • head f1ff5eb:cargo test --test issue2769_death_notice_line_stamp_regressions → 5 passed / 0 failed(SIGXFSZ 两格 fg/subshell_member 在真信号死亡下绿)。
  • base e50cea9:同 stem → 2 passed / 3 failed。红集 = {eof_notice_stamps_one_past_the_last_line(stderr 整条 Killed 通知丢失), fg_notice_stamps_the_dying_commands_own_line(line 3 vs 期望 2), subshell_member_notice_stamps_the_compound_end_line(line 7 vs 期望 6)}。
  • 与审计预期出入说明:预期 fg/subshell 两格红,实际 eof 格也红——base 的 reader-边界排队在 EOF 处直接把通知丢了(无下一边界可触发),比「错位印章」更重但同根因(jobs.c:3385 wait 内同步 notify 未实现)。三红全在修复面,两 boundary 格双边绿。fail-first 成立。

未动代码;其余腿按第1轮审计记录全绿。判词翻 PASS,按协议 squash 合并。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 15, 2026 04:44
@caomengxuan666
caomengxuan666 merged commit f72b5c2 into master Nov 15, 2026
8 of 11 checks passed
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.

1 participant