Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Commit 78037ad

Browse files
committed
fix(runtime): pass -- before negative pgid so group kill works on Ubuntu
Ubuntu's procps kill exits 0 on 'kill -TERM -<pgid>' without signaling anything, so the process-group kill silently no-opped and runtime IO cleanup waited out the descendant's full sleep. Add the '--' separator (verified on ubuntu:24.04, Debian trixie, and macOS) and restore the 2s IO shutdown grace now that the kill actually lands. Also make the core pipefail-rerun test expect None on Windows, where pipeline_rerun_command intentionally suppresses the bash suggestion.
1 parent d922c24 commit 78037ad

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

crates/tokenzero-core/src/tests.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,16 @@ fn shell_c_wrappers_detect_masked_inner_pipeline_failures() {
516516
.is_some_and(|warning| warning.contains("mask")),
517517
"{command}: {status:?}"
518518
);
519+
// pipeline_rerun_command suggests a bash rerun, which is suppressed
520+
// on Windows where bash is not assumed to exist.
521+
let expected_rerun = if cfg!(windows) {
522+
None
523+
} else {
524+
Some("bash -o pipefail -c 'false | true'")
525+
};
519526
assert_eq!(
520527
status.pipeline_rerun_command.as_deref(),
521-
Some("bash -o pipefail -c 'false | true'"),
528+
expected_rerun,
522529
"{command}"
523530
);
524531
}

crates/tokenzero-runtime/src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,10 @@ fn deadline_from(start: Instant, timeout: Duration) -> Instant {
621621

622622
fn process_io_shutdown_grace() -> Duration {
623623
// After terminating the group, give the IO workers room to observe the pipe
624-
// close and drain. A heavily loaded CI runner can take noticeably longer than
625-
// a quiet desktop to propagate the kill and unblock the reader, so this stays
626-
// generous while remaining well under any realistic background-descendant
627-
// sleep so cleanup is still demonstrably prompt.
628-
Duration::from_secs(5)
624+
// close and drain. Kept well under the 5s descendant sleeps in the runtime
625+
// tests so a regression in the group kill fails loudly instead of being
626+
// absorbed by the grace window.
627+
Duration::from_secs(2)
629628
}
630629

631630
/// IO wait after the main child has already EXITED: an exited process
@@ -676,16 +675,21 @@ fn terminate_unix_process_group(pgid: u32) {
676675
if pgid == 0 {
677676
return;
678677
}
678+
// The "--" separator is load-bearing: Ubuntu's procps kill accepts
679+
// `kill -TERM -<pgid>` with exit 0 yet signals nothing, so the group
680+
// kill silently no-ops without it (Debian and macOS tolerate both).
679681
let target = format!("-{pgid}");
680682
let _ = Command::new("kill")
681683
.arg("-TERM")
684+
.arg("--")
682685
.arg(&target)
683686
.stdout(Stdio::null())
684687
.stderr(Stdio::null())
685688
.status();
686689
thread::sleep(Duration::from_millis(50));
687690
let _ = Command::new("kill")
688691
.arg("-KILL")
692+
.arg("--")
689693
.arg(target)
690694
.stdout(Stdio::null())
691695
.stderr(Stdio::null())

0 commit comments

Comments
 (0)