Repository navigation
Refs #3802 - #3805
Refs #3802#3805
Conversation
Fail-first nails: a SIGKILL'd background job must list as Killed (seed_r118a checks 2-3), SIGTERM as Terminated, and a plain exit 137 must keep rendering Exit 137. GNU jobs.c:1969-2015 printable_job_status: WIFSIGNALED prints j_strsignal(WTERMSIG); only a plain nonzero exit prints Exit %d. Refs #3802
|
【Y3-AUDIT】PR #3805 第1轮 — 建议:PASS(钉已就位且与 GNU 一致;注意:本 PR 当前仅含回归钉,修法未落——合入前必须等修法提交,否则会给 master 带进 3 条新红) 机制核查:
腿:
钉质量专项(本批钉审口径):
F 点:无 未跑/VOID 的腿:lib 双边(构造性等价,diff 仅 +tests/ 文件);fail-first 独立 base 构建(同上等价性) |
|
【Y3-AUDIT】判词更正:#3805 当前仅含回归钉、修法未落,按批次口径应记 建议 PENDING(缺修法腿),不进入 merge 队列。钉本身已验证(见上条报告)。 |
#3802) GNU printable_job_status (jobs.c:1969-1985) renders a signal death as `j_strsignal (WTERMSIG (p->status))` — `Killed` for SIGKILL, `Terminated` for SIGTERM — and only a plain nonzero exit as `Exit %d`. Windows ExitStatus carries no WIFSIGNALED bit, and this shell's own `kill` encodes a kill as TerminateProcess (128 + signal) (builtins/kill.rs signal_process), so a SIGKILL'd background job reaped with exit code 137 and the table printed `Exit 137`. Record the terminating signal at the shared delivery bookkeeping site (`note_kill_delivery`, the one place the single-pid and jobspec paths both pass) in JobTable::delivered_signals, and consume it at apply_job_completion: when the platform wait status has no signal, the record supplies it for note_term_signal, so the row renders GNU's description. A plain `exit 137` leaves no record and keeps `Exit 137`; a re-registered pid drops a stale record. Verified against WSL GNU bash 5.3.20 from a script file: KILL/TERM rows and the `exit 137` control are byte-identical after PID normalization. Pin issue3802_jobs_table_killed_wording 4/4 (3 red at the branch's base commit).
|
【o1 收网验证 · 建议 PASS】head Y3-AUDIT 第1轮/更正(PENDING=缺修法腿)已回应:修法已落,机制如下。
腿:
关联 #3802:本 PR 覆盖 issue 描述的全部形状(KILL/TERM 表行措辞 + 单一死亡报告 + |
|
【P1 车道复核 — 已合入后的残余回归】#3805 的修法在 Linux 上把「被 kill 过但最终正常退出」的 job 误判成信号死亡 本 PR 已合入(merge
根因(GNU 锚点)GNU 当前实现
Linux 上正常退出的 建议修法(保持 #3802 的全部钉绿)
替代方案是把该 fallback 整体 请后续车道补一格 pin: |
… (Refs #3802) (#3841) #3805 made the jobs table name the signal this shell's own kill delivered, decoding the Windows `TerminateProcess (128+signal)` exit code against a per-pid delivery record. The decode was unconditional: `take_delivered_signal(pid)` ignored the reaped status, so on unix a job that ignored or trapped SIGTERM and then exited on its own was rendered from the record instead of its wait status -- `trap "" TERM; exit 5` printed `Terminated` where GNU prints `Exit 5`, and `trap "exit 143" TERM` printed `Terminated` where GNU prints `Exit 143`. GNU decides the wording from the wait status alone: jobs.c:1969-2015 printable_job_status() calls j_strsignal(WTERMSIG(p->status)) only in the WIFSIGNALED arm, and the WIFEXITED arm always renders `Exit %d` (jobs.c wait_for reaps the status; kill_pid, jobs.c:3988-4007, is pure delivery and never proof of death). A code equal to 128+signal is not that proof: an `exit 143` is WIFEXITED. Owner split: - unix: the kernel wait status is authoritative (exit_status_signal), so the delivery record is only consumed, never applied (JobTable::discard_delivered_signal); - Windows: no WIFSIGNALED exists, so the record supplies the signal only when the reaped code is exactly 128+signal (take_delivered_signal(pid, status)). Oracle: WSL GNU bash 5.3.20 script files vs the fixed Linux binary, 5 shapes x {jobs-then-wait, wait-then-jobs} -- byte-identical except the pre-existing Killed notice path (shell path/pid, #3803 face): a. trap "" TERM; exit 5 -> [1]+ Exit 5 rc=5 b. trap "exit 143" TERM -> [1]+ Exit 143 rc=143 c. kill -9 (real SIGKILL) -> [1]+ Killed rc=137 d. kill -TERM default -> [1]+ Terminated rc=143 e. plain exit 7 -> [1]+ Exit 7 rc=7 Fail-first on master: a/b print Terminated. Pins: tests/issue3802_delivered_signal_guard.rs 5/5 (trapped shapes `#[cfg(unix)]`; Windows now has no in-child signal disposition), plus the #3805 pin 4/4 on Windows and Linux. Neighbouring jobs/wait stems unchanged (issue2340's two reds are identical on master).
Refs #3802
UNVERIFIED-BY-CAPTAIN
Root cause
GNU
jobs.c:1969-2015printable_job_statusrenders a job that died by a signal with the signal description (j_strsignal (WTERMSIG (p->status))—Killedfor SIGKILL) and only a plain nonzero exit asExit %d. The distinction is the wait status's WIFSIGNALED bit, which WindowsExitStatusdoes not carry: rubash's ownkillencodes the kill asTerminateProcess (128 + signal)(src/builtins/kill.rssignal_process), so a SIGKILL'd job reaps with exit code 137 and no recorded signal, and the table rendered[1]+ Exit 137 sleep 30.Fix (in progress): record the signal this shell's own
killdelivered (JobTable, via the sharednote_kill_deliverybookkeeping site) and decode the reap against it at the boundary sweep, so the table rendersKilled/Terminated. A plainexit 137keeps renderingExit 137— the signal is attributed only from the shell's own kill record, never from the exit code alone. No change tosrc/builtins/wait.rsor the notification emission path (#3803's face).Regression nails
tests/issue3802_jobs_table_killed_wording.rs(fail-first on Windows/X299; the KILL/TERM legs already pass on Linux via the wait status):jobsrow containsKilled, noExit 137;waitstill reports 137kill -KILL-> sameTerminated, noExit 143;waitstill reports 143exit 137-> stillExit 137, neverKilled本 PR 删除了什么
无删除:只新增回归钉(本提交);修法提交随后。
Verification
RUSTFLAGS="-D warnings" cargo check, rustfmt --check修法(26769c2f7 已落)
note_kill_delivery(单 pid 与 jobspec 两条投递路径共用的唯一记账点)把终止信号记入JobTable::delivered_signals;apply_job_completion在平台 wait status 无信号时取出该记录交给note_term_signal,render_background_jobs已有的term_signal → signal_death_description分支即打印 GNU 的Killed/Terminated。控制格exit 137没有投递记录,保持Exit 137;pid 重新注册会丢弃旧记录。GNU 锚点:jobs.c:1969-1985
printable_job_status(WIFSIGNALED →j_strsignal(WTERMSIG),否则Exit %d)。验证:钉 4/4(base 308e97f:3 红 1 绿);WSL GNU bash 5.3.20 脚本文件三格(KILL/TERM/exit 137)PID 归一后逐字节一致;lib 差集空(issue2084 环境);warnings/fmt 净。