Skip to content

WIP: jobs surface — #2214 subshell start-notice gate + #2203 suspend single-generation stop - #2231

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/jobs-2214-2203
Oct 30, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/jobs-2214-2203

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

WIP: jobs-surface pair — two commits, one per issue. Full evidence in the cluster REPORT (kept with the working tree).

Refs #2214 — stray async start notices from subshell environments

GNU prints the start notice via DESCRIBE_PID (execute_cmd.c:609 — if (interactive) describe_pid (pid), jobs.c:1947), and every subshell environment clears interactive (execute_cmd.c:1637 execute_in_subshell). rubash's notify_async_job_started checked only the session __RUBASH_INTERACTIVE marker, which fork copies carry into subshell environments, so children backgrounded inside ( ), $( ), pipeline stages and process substitutions printed stray [1] <pid> notices (field shape: interactive nvm ls).

  • notify_async_job_started now also returns early in in_subshell_environment().
  • Same chokepoint, opposite direction: the coproc spawn never notified at all; GNU does print for coproc (execute_cmd.c:2580, PTY-verified) — the site now routes through the same gated notify.
  • Pin: tests/issue2214_job_start_notice_regressions.rs — 9 pipe--i sessions. Baseline-red on master: all 5 zero-notice shapes, the brace-group inner spawns, and the coproc case fail; the 2 pure controls pass on both trees. Fixed tree: 9/9.

Refs #2203 — suspend -f lost wakeup (cli_tests flake, 10 CI sightings)

Characterized as a real product defect, not harness timing. GNU sends ONE stop generation (killpg (shell_pgrp, SIGSTOP), builtins/suspend.def; jobs.c:4737). In this multithreaded executor:

Fix (Linux): every OTHER process in the group gets its own process-directed SIGSTOP (enumerated via /proc), and this process stops solely through the thread-directed tgkill — prompt at its own exit path, and as the only in-process generation it is fully consumed by the episode. Non-Linux unix keeps the #1474 pthread_kill clamp; /proc-unavailable falls back to the historical path (documented in code).

Validation (Linux, loaded VM): fixed binary 0/40 second-CONT and 0/20 tail-runs; master binary 14/40 second-CONT. tests/issue2203_suspend_single_cont_regressions.rs (12 rounds, exactly one SIGCONT, alternating pid/group addressing) is red on master, green on the fix; the #1474 timing pin passes 20/20; the cli_tests carrier test is unchanged and passes deterministically (0.14s vs the 10.1s timeout failures).

An intermediate sched_yield variant was implemented and rejected by evidence (resume-clean, but the stop landed 1–2 commands late in 7/30 runs, regressing #1474) — the ladder of measured variants is in the commit message and code comments.

…e session

GNU prints the async start notice through DESCRIBE_PID
(execute_cmd.c:609: if (interactive) describe_pid (pid), jobs.c:1947),
and every subshell environment clears interactive
(execute_cmd.c:1637 execute_in_subshell). notify_async_job_started
checked only the session __RUBASH_INTERACTIVE marker, which fork
copies carry into subshell environments, so children backgrounded
inside ( ), $( ), pipeline stages and process substitutions printed
stray [1] <pid> notices (field shape: interactive nvm ls). The notify
now also returns early in in_subshell_environment(), the executor's
existing model of that boundary. The coproc spawn site registered
its job but never notified; GNU prints for coproc too
(execute_cmd.c:2580), so it now routes through the same gated notify.

Pin: tests/issue2214_job_start_notice_regressions.rs (9 pipe -i
sessions; baseline-red on master for the 5 subshell shapes, the
brace-group inner spawns, and the coproc case).

Refs #2214
…round the executing thread

GNU suspend_builtin sends exactly one stop generation,
killpg (shell_pgrp, SIGSTOP) (builtins/suspend.def; jobs.c:4737
shell_pgrp), and its single thread dequeues it at the killpg exit.

In this multithreaded executor a bare killpg does not stop the
RUNNING executing thread promptly (the kernel wakes a sleeping
thread to dequeue the process-directed stop; post-suspend commands
executed in 28/30 harness runs — the rubash#1474 defect). The #1474
clamp added a thread-directed SIGSTOP after killpg: prompt, but
the two pendings coexist — the one the executing thread does not
dequeue survives the stop episode and re-stops the group after
the first SIGCONT, so fg's single SIGCONT did not resume the
shell (14/40 supervised rounds on master; the cli_tests
suspend_force flake, 10 CI sightings, and the same lost wakeup
recorded in the #1474 pin header per rubash#1637).

Linux fix: every OTHER process in the group gets its own
process-directed SIGSTOP (enumerated via /proc), and this process
stops solely through the thread-directed tgkill — prompt at its
own exit path, and as the only in-process generation it is fully
consumed by the episode: one SIGCONT resumes. Validated against
a two-thread harness and the real binary: 0/40 tail-runs and
0/40 second-CONT, vs 14/40 second-CONT for the master build.
Non-Linux unix keeps the #1474 pthread_kill clamp; /proc
unavailable falls back to the historical killpg + tgkill path.

Pin: tests/issue2203_suspend_single_cont_regressions.rs — 12
supervised rounds alternating pid-/group-addressed exactly-one
SIGCONT (baseline-red on master). The cli_tests carrier test is
unchanged and passes deterministically now.

Refs #2203
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