Skip to content

WIP: fix(jobs): disown -r deletes/marks only running jobs (#2496) - #2505

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/2496-disown-r-set
Nov 1, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/2496-disown-r-set

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #2496

disown -r deleted (and disown -h -r marked) the WHOLE job table. GNU restricts both arms to running jobs — cluster E found this while pinning #2488/#2489 (its REPORT §5); this PR is the follow-up cluster F fix, stacked on E's branch.

GNU semantics (bash 5.3 sources)

  • delete_all_jobs (running_only) (jobs.c:5066): a job is deleted only when running_only == 0 || ISRUNNING (job) (jobs.c:5091). Before the sweep it clears the current/previous markers (js.j_current = js.j_previous = NO_JOB, jobs.c:5078-5079), and deletion goes through delete_job with DEL_NOBGPID — a deleted job's pid stops being a waitable child.
  • nohup_all_jobs (running_only) (jobs.c:5111): same JRUNNING filter for the -h marking arm.
  • A stopped job is therefore never deleted by -r, never raises the DEL_WARNSTOPPED warning there, and keeps answering wait %n (147 + the wait_for_job warning) and fg %n.

Change

  • execute_disown All arm, running_only delete branch: collect Running-state job ids, remove each with the same child/fd cleanup the per-spec paths use (background_children drop, coproc endpoints, fd table), then remove_job (purges pid map + retained statuses, DEL_NOBGPID parity); afterwards clear the table's current/previous markers like jobs.c:5078-5079. New helper JobTable::clear_current_markers.
  • nohup_only arm: with running_only, only Running jobs get the nohup mark.
  • The plain (no -r) arm is untouched — E's shell exit with a stopped job misses GNU's 'deleting stopped job' warning #2489 warning loop and full clear_jobs are byte-identical, so no warning behavior changes.

Verification

  • New pins tests/issue2496_disown_r_set.rs — 8 tests, 8/8 green under the scrubbed-fd runner (logs in the cluster workdir). Every shape was byte-compared against the GNU bash 5.3.20 oracle binary (identical modulo pid values): list shape incl. marker clearing, stopped survivor waitable (147 → CONT → 0) and fg-able, deleted running pid → wait 127 "not a child", completed job kept, -h -r lists unchanged, sole-running-job table emptying, disown -a guard.
  • Two faces are documented in the pin file as not byte-pinnable: GNU's own Done listing line is racy across identical runs, and -h -r's marking scope is observable only on the interactive hangup path — the pin covers the deterministic subsets; both behaviors follow the jobs.c state condition/filter in code.
  • E's pins stay green on this tree: issue2488 3/3, issue2489 6/6; issue1304 1/1. cargo check clean; per-file rustfmt applied.

Base / landing

Base is E's branch fix/2488-2489-job-warnings (PR #2494) because the fix builds on the running_only plumbing E added to the disown parser — do not merge before #2494. After E lands, the captain rebases this branch onto master and readies the PR.

Residual (not this issue; for the captain's ledger)

Adjacent wait face found while shaping the pins, reproducible WITHOUT any disown: set -m; sleep 30 & p=$!; kill -STOP $p; <poll>; kill -CONT $p; kill -KILL $p; wait $p → GNU returns 147 silently (recorded stop status), rubash returns 137 and prints the Killed job notice — rubash's wait observes live reap state where GNU answers from the last waitchld-recorded state (the deferred job-state family). Details in the cluster REPORT.

@caomengxuan666
caomengxuan666 changed the base branch from fix/2488-2489-job-warnings to master November 1, 2026 18:07
GNU delete_all_jobs (running_only) (jobs.c:5066) deletes a job only
when running_only == 0 || ISRUNNING (job) (jobs.c:5091), after
clearing the current/previous markers (jobs.c:5078-5079);
nohup_all_jobs (jobs.c:5111) applies the same JRUNNING filter to the
`disown -h` marking arm. The executor's All arm ignored running_only
and cleared / marked the whole table (cluster E REPORT section 5).

- disown -r now deletes only Running jobs, with the same child/fd
  cleanup as per-spec disown so deleted pids stop being waitable
  children (DEL_NOBGPID parity); stopped and completed jobs survive,
  and the current/previous markers are cleared like GNU
  (JobTable::clear_current_markers).
- disown -h -r marks only Running jobs.
- The plain arm is unchanged: E's #2489 warning loop and the full
  clear_jobs stay byte-identical.

New pins tests/issue2496_disown_r_set.rs (8 tests), every shape
byte-compared against GNU bash 5.3.20; issue2488 (3/3) and issue2489
(6/6) pins stay green.

Refs #2496
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 1, 2026 18:30
@caomengxuan666
caomengxuan666 merged commit 15b457f into master Nov 1, 2026
11 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/2496-disown-r-set branch November 2, 2026 01:10
@caomengxuan666

Copy link
Copy Markdown
Member Author

[win-acceptance] #2505 PASS — pin issue2496_disown_r_set is #![cfg(unix)] (0 tests on Windows by design); live probe on Windows is byte-identical to WSL GNU Bash 5.3.20 (pids normalized): running sleep deleted by disown -r, STOPPED sleep survives in the jobs listing, stays waitable after CONT (status lines and rc sequence identical) — probe D:/repo/win-accept/wave2/probes/p2496.*. E's warning faces (#2488/#2489) re-verified green in the same session (see the #2494 reply).

Environment: Windows 10 19045 real machine, MSVC Rust debug build of master 9348b8d (contains this merge). No BLOCKER.

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