Skip to content

fix(jobs): publish wrapper relay target for simple-command waits (#2983) - #3976

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/2983-wrapper-relay-simple-wait
Nov 20, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/2983-wrapper-relay-simple-wait

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #2983 — UNVERIFIED-BY-CAPTAIN

Root cause (one line)

The background wrapper's simple-command wait (wait_external_child) never published a WrapperRelayTargetGuard, so a group-delivered SIGINT found no relay target: the wrapper re-raised and died, and the #737 PDEATHSIG arm SIGKILLed the script child before its INT trap could run — bats file_setup_teardown #8 lost teardown_file.

Fix

src/executor/external_inner.rs (+17): publish WrapperRelayTargetGuard::publish(child.id()) for exactly the span of wait_external_child — the same mechanism the pipeline path has used since #2626 (pipeline_exec.rs). GNU interposes no wrapper (jobs.c wait_for semantics: delivery reaches the job's processes directly), so the wrapper must stay transparent to addressed/group signals on every wait shape, not only pipelines. The guard is inert outside wrapper-role processes and off unix. Plus one regression pin (+78, #[cfg(unix)]).

This is fix #2 of #2983; fix #1 (attribute-transport leak) already landed via the journal gate (#3736). The earlier guard-block against touching this area (proximity to #3538) no longer applies: #3538 is closed, superseded by merged #3746.

Verification (GNU bash 5.3.20 oracle, bats-core 1.11.0)

  • Stock test/file_setup_teardown.bats, release build, cloud host: master filter "user abort" → not ok 1 (line 118, teardown log missing); fixed filter → ok 1, full file 17/17 ok; oracle full file 17/17.
  • Deterministic-entry driven probe (wrapper-forcing trap-table + fd-4 shape, poll until the fixture's sleep 10 is in the job's group, then kill -SIGINT -- -$!): master → wait rc=130, LOG MISSING; fixed → LOG written by teardown_file. Reproduced identically on the local VM and the cloud host.
  • New pin issue2983_wrapper_simple_wait_relays_group_sigint_to_script_child: fail-first against master code (1 failed / old pin passed), passes with the fix; pin file 2/2.
  • Adjacent suites vs master (cloud): 2982 3/3, 866 4/4, 2729 3/3, 2241 5/5, 2053 4/4 — all green on both. 1825 (1 failure) and 1990_1991 (3 failures) fail with identical test sets on master and fixed — pre-existing reds, untouched by this change.
  • Windows face (X299, MSVC debug build): kill forms (-l, group/pid ESRCH rc and message, -9 -- -1) and jobs/wait smoke are byte-identical between master and fixed binaries; the relay publish is inert off unix by design. The pre-existing issue2983 pin already fails on Windows at master (POSIX shape, ungated); the new pin is #[cfg(unix)]-gated so it adds no Windows red.

Notes for the captain

  • On slow/contended machines the debug build fails Fix winuxsh compatibility regressions #8 under both binaries: the stock test's fixed sleep 2 entry window is shorter than rubash's startup through the trap-heavy bats chain (kill lands during the inner run's gather phase, before bats-exec-test exists). The release build is the verification of record; the driven probe above removes the timing race without changing the shape.
  • Local VM note: this lane's local sandbox intermittently denied exec writes (EPERM on git objects/rustc) mid-session; the branch was therefore assembled via the GitHub git API from byte-identical blobs (blob SHAs c3ea05b0 / 49c98a50 match a local commit of the same tree made on the cloud host, b62ff7a). A git bundle of that commit is kept on the cloud host at ~/rubash2983-fix2983.bundle as backup.

A background job that takes the --internal-bg-wrapper path waited on
its script child through wait_external_child without publishing a
WrapperRelayTargetGuard. A group-delivered SIGINT (kill -SIGINT
-- -$!, the bats CTRL-C shape) therefore found no relay target: the
wrapper restored its saved disposition and re-raised, dying by the
signal, and the rubash#737 PDEATHSIG arm then SIGKILLed the script
child before its INT trap could run — bats file_setup_teardown #8
lost teardown_file. The pipeline path has published the target
since rubash#2626; the simple-command wait now does the same for
exactly the span of the wait. GNU interposes no wrapper (jobs.c
wait_for job-wait semantics: delivery reaches the job's processes
directly), so the wrapper must stay transparent to addressed and
group-delivered signals.

Verification (GNU bash 5.3.20 oracle; bats-core 1.11.0):
- stock test/file_setup_teardown.bats, release build: master
  filter "user abort" not ok (line 118, teardown log missing);
  fixed filter ok and full file 17/17; oracle full file 17/17.
- new pin issue2983_wrapper_simple_wait_relays_group_sigint_to_
  script_child (cfg(unix)): fail-first against master code,
  passes with the fix; the pre-existing issue2983 pin is
  unchanged and green.
- adjacent suites 2982/866/2729/1825/2241/1990_1991/2053: no new
  reds vs master; the 1825 (1) and 1990_1991 (3) failures are
  identical pre-existing sets on master and fixed.
- Windows (X299): kill-form and jobs probes byte-identical
  between master and fixed binaries; the relay publish is inert
  off unix by design.

Refs #2983

UNVERIFIED-BY-CAPTAIN
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 20, 2026 09:07
@caomengxuan666
caomengxuan666 merged commit 6992501 into master Nov 20, 2026
9 of 12 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