From 74e2f807ddf2cf0d524c042998726f9cd41101b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 23 Oct 2026 15:31:06 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20wait=20for=20SIGKILLed=20jo?= =?UTF-8?q?b=20processes=20to=20exit=20before=20checking=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The executor reaps the job cgroup before run_job returns, and the cgroup is gone by then. A SIGKILLed process leaves its cgroup before it finishes exiting, so a single /proc check right after could still see it in state D. Poll for up to 5 s instead. --- .../forge-runner/tests/integration/builtin.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/forge-runner/tests/integration/builtin.rs b/crates/forge-runner/tests/integration/builtin.rs index b569211..5802d1b 100644 --- a/crates/forge-runner/tests/integration/builtin.rs +++ b/crates/forge-runner/tests/integration/builtin.rs @@ -253,6 +253,19 @@ fn process_gone(pid: u32) -> bool { } } +/// Waits up to five seconds for `pid` to exit. A SIGKILLed process leaves its cgroup before it +/// finishes exiting, so a single check right after the cgroup is gone can still see it running. +async fn wait_gone(pid: u32) -> bool { + let deadline = Instant::now() + Duration::from_secs(5); + while !process_gone(pid) { + if Instant::now() >= deadline { + return false; + } + tokio::time::sleep(Duration::from_millis(20)).await; + } + true +} + /// The helper is SIGKILLed while its job is still running, so it cannot tear the container down. /// The executor must then kill the job's processes, remove its cgroup, and remove its job dir. #[tokio::test] @@ -298,7 +311,10 @@ async fn sigkilled_helper_leaves_no_process_behind() { cgroup.display() ); for pid in &procs { - assert!(process_gone(*pid), "job process {pid} survived the helper"); + assert!( + wait_gone(*pid).await, + "job process {pid} survived the helper" + ); } assert!(!dir.path().join("jobs/job_01").exists(), "job dir was kept"); }