Repository navigation
fix(executor): publish Running at kill -s CONT delivery on a recorded-stopped job - #3642
Merged
Merged
Conversation
…-stopped job (Refs #2666) GNU jobs.c:4013-4018 kill_pid: a SIGCONT aimed at a job the table already records as stopped emulates bg — set_job_running flips every WIFSTOPPED member and JOBSTATE at delivery time (with J_NOTIFIED), not at the next notification point. rubash deferred the Running mark like the stop side, so the jobs.tests pair after 'kill -s CONT %2' still listed the job under 'jobs -s' and dropped it from 'jobs -r' — the run-jobs lane residual in #2666. A CONT toward a still-running job or one whose stop is not yet recorded keeps the deferred path. Refs #2666 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
marked this pull request as ready for review
November 16, 2026 12:28
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:无 |
This was referenced Nov 16, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
Refs #3637 ## 根因 signal-killed 异步作业的死亡通知(`bash: line 1: PID Killed <cmd>`)在两种情形下出错: 1. **丢失**:作业在 intervening foreground 外部命令等待期间被 reap,通知进入 `pending_signal_notices` 队列;随后的 `wait $p` 只排空 wait 当次产生的通知(`queue[mark..]`),预先排队的通知留在队列里;`-c` 单 list 结束时驱动丢弃剩余队列,通知永不打印。 2. **翻倍**:`jobs` 先列出死亡作业(render 标记 notified),随后 `jobs` 内置命令后的 `report_pending_signal_notices()` 冲刷仍把队列里的同一通知打印一次 —— 冲刷路径没有任何 IS_NOTIFIED 守卫。 GNU 锚点(bash-5.3,`third_party/bash/`;本地对照 `~/workspace/rubash-audit/build-gnu/bash-5.3/`): - `jobs.c:3385` `wait_for` 调用 `notify_and_cleanup(job)` —— wait 打印所等作业的通知。 - `jobs.c:3434-3437` `wait_for_job` 在应答后标记 `J_NOTIFIED`。 - `jobs.c:3474`/`3486` `wait_for_any_job` 扫描未通知的死亡作业并 `notify_of_job_status`。 - `jobs.c:3642` `notify_and_cleanup` = `maybe_print_job_notifications` + `cleanup_dead_jobs`。 - `jobs.c:4570` `notify_of_job_status` 以 `IS_NOTIFIED (job) == 0` 为整打印守卫。 - `jobs.def:141`/`172` `jobs` 先列出作业再 `notify_and_cleanup(-1)`。 ## 修复(机制修,两面同修) 1. `Executor::wait_notice_pids: Vec<u32>`(`src/executor/mod.rs`):记录一次 `wait` 经已完成臂解析的 pid;两个穷举字面量构造点(`init.rs`、`command_substitution.rs`)以 `Vec::new()` 补齐。 2. 已完成臂(`wait_for_background_pid`)解析时 push pid。 3. `execute_wait` 在 inner wait 前清空、后排空:除 wait 当次产生的通知外,另取走预先排队且属于本次解析 pid 的通知(只取所等作业的,不取其它作业的),经 wait 自身 fd-2 路由(#1303 纪律)。 4. `emit_signal_notices` 增加 IS_NOTIFIED 守卫:作业表里已标记 notified 的 pid 不再打印(边界 / 流结束 / `jobs` 冲刷路径)。wait 的排空直接走 `format_signal_notices`、有意绕过该守卫 —— wait 本身就是通知点(jobs.c:3385),且 wait 的记账在排空前已标记所等作业 notified;若守卫放在 formatter 里会破坏当前已工作的即时 wait 与 bare wait 通知。无作业表条目的 pid 仍打印(前台通知与 procsub 角,行为不变)。 #3642 的 CONT 面(`limit_builtins.rs` + `tests/issue3637_kill_cont_stopped_job.rs`)未动;其钉在邻居腿中 1/1 通过。 ## 本 PR 删除了什么 无删除。仅新增 `wait_notice_pids` 字段与回归钉;无公开 API 变动,无行为删除。 ## 验证(Linux) - fail-first(base 88fd543):seed `seed_r118a.sh`(rubash 作驱动)4/9,检查 1–5 失败、控制项通过;GNU 9/9。注:`BASH=<sut> bash seed.sh` 会因 bash 重置 `$BASH` 而空跑,必须以 shell under test 作驱动。 - 修绿:seed 9/9;回归钉 `tests/issue3637_async_death_notice_regressions.rs` 8/8。 - 邻居:issue1604 1/1、issue3637_kill_cont_stopped_job(#3642 钉)1/1、issue1494 2/2、issue2340 9/9(首跑 1 格翻转,重跑 9/9 —— 时序抖动)、issue1048_1256 5/5、issue2735 3/3、issue2769 5/5、issue2928 6/6、issue1303 被忽略的单测 `--ignored` 6/6(文档化残差未复现);issue2398 1/2 与 issue2697 3/5 —— 两红均在 **base 上逐格相同**,为既存红(2398:kill→wait reap 竞态;2697:#2697 自身的 subshell 命名面),非本 PR 回归。 - `RUSTFLAGS="-D warnings" cargo build --locked --bin rubash` rc=0;`cargo check --locked --lib --bins` rc=0;marker-lint OK;rustfmt clean;LF 行尾。 ## 验证(X299 / Windows) - 构建:修后与 base 在 X299 上均 `cargo build --locked --bin rubash` rc=0(各约 1m05s)。钉为 `#![cfg(unix)]`,Windows 上不跑;X299 腿 = 构建 + seed 在 `rubash.exe` 下的复核。 - Seed(`seed_r118a.sh`,rubash.exe 作驱动):base 3/9 → 修后 **6/9**。**丢失面已修**:检查 1、4、5 由 FAIL→PASS。 - 翻倍面(检查 2、3)在 Windows 上读数为 0:修后输出仅有 jobs 表一行 `[1]+ Exit 137 sleep 30`,无 stderr 通知。直接对照探针(`sleep 30 & kill -9 %1; sleep 0.2; jobs; wait %1`)证明:base 的表行同样是 `Exit 137`,其 seed 计数 1 来自**翻倍的 stderr 通知**(`60736 Killed sleep 30`),修后该通知被正确抑制。行为(恰一次死亡报告 = 表行)正确;seed 的 `Killed` 字数假设在 Windows 上不成立 —— Windows 表行把死亡渲染为 `Exit 137` 而非 `Killed`,为既存 Windows 措辞面,宜另立单。 - 控制项即时 wait(检查 6)在 Windows 上 base 与修后均失败(无通知):wait 自身 reap 的通知在 Windows 上不打印 —— 既存 Windows 面缺口,宜另立单。 - Base 另见 `wait: %1: no such job`(kill→wait reap 竞态,与 issue2398 同源),修后该形状无此报错。 ## 队长复核(CAPTAIN-VERIFIED) - 机制与 GNU 锚点已核;#3642 CONT 面零文件重叠(limit_builtins.rs + 其钉未动),其钉 1/1。 - CI(头 3895de7,run 43907000596):goldens 仅 2 格基线红(issue_753::case_9、upstream_suite_slice_snapshots);census 首跑 89 格中 2 格超 master(issue1902_stdout_stderr_names_follow_their_bindings、star_at_a_quoted_with_colon_ifs_is_one_word),重跑(attempt 2)85 格、全在 master 基线内、新钉绿 —— 两格裁为抖动(同头重跑消失;旧头与 master 上皆绿);Rust tests (macOS) 首跑 infra 取消(steps=[],master 同跑亦取消)→ 重跑 SUCCESS。 - 与现尖 5d253cf 的漂移(f56716b5...5d253cf,10 文件)与本 PR 5 文件零交集,按零交集例外合入,不再 update-branch。 - Windows 残差两面(Exit 137 渲染、check-6 无通知)为既存缺口,另立单跟进,不属本 PR 回归。
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.
Summary
kill -s CONT %jobon a job the table already records as stopped now flips it to Running at delivery time, matching GNUjobs.c:4013-4018(kill_pidemulatesbghere:set_job_running+J_NOTIFIED), instead of deferring the mark to the next notification point. Thejobs.testskill -s CONT %2→jobs -r/jobs -spair now renders byte-identical to GNU 5.3.20 — run-jobs lane residual cleared.A CONT toward a still-running job (or one whose stop has not been recorded yet) keeps the deferred path from rubash#1494. Pinned by
tests/issue3637_kill_cont_stopped_job.rs(fail-first verified).Refs #2666