From 0a6ab6564b40915c4bab00aad4c84a8ad283d49a Mon Sep 17 00:00:00 2001 From: MrScripty Date: Fri, 6 Nov 2026 12:21:17 -0700 Subject: [PATCH] test(platform): wait boundedly for the drained Windows descendant to signal suspended_admission_assigns_descendants_to_job_and_drains_them polled the terminated descendant's process handle once with a zero timeout right after terminate_and_drain. Drain completes when the Job reports no active processes, and Windows can drop that count shortly before the terminated process object is signaled, so the poll intermittently returned WAIT_TIMEOUT (258) on CI (#111 and #113 runs on 2026-11-06). Wait up to five seconds instead. The test still proves the descendant was assigned to the Job and terminated by the drain. Co-Authored-By: Claude Opus 5.5 --- rust/crates/pumas-core/src/platform/managed_child.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/crates/pumas-core/src/platform/managed_child.rs b/rust/crates/pumas-core/src/platform/managed_child.rs index 7f1cb543..8bff2878 100644 --- a/rust/crates/pumas-core/src/platform/managed_child.rs +++ b/rust/crates/pumas-core/src/platform/managed_child.rs @@ -1485,9 +1485,12 @@ mod windows_tests { assert_ne!(member, 0, "descendant escaped the admitted Job"); child.terminate_and_drain(Duration::from_secs(10)).unwrap(); // The retained handle names the same process even after its PID can be reused. + // Drain completes when the Job reports no active processes; Windows can + // drop the Job count shortly before the terminated process object is + // signaled, so allow a bounded wait rather than polling it once. assert_eq!( // SAFETY: OwnedHandle keeps the process handle live through this wait. - unsafe { WaitForSingleObject(process.as_raw_handle(), 0) }, + unsafe { WaitForSingleObject(process.as_raw_handle(), 5_000) }, WAIT_OBJECT_0 ); assert!(!windows::terminate_and_has_members(&child.job).unwrap());