Skip to content

Commit 86f29e3

Browse files
Bound Rust E2E child reaping
Replace blocking waits after proxy termination with deadline-bounded try_wait polling so startup and shutdown failures cannot hang the test process. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 73edf08 commit 86f29e3

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

rust/tests/e2e/support.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,8 @@ fn wait_for_child_exit(child: &mut Child) -> std::io::Result<()> {
713713
if child.try_wait()?.is_some() {
714714
return Ok(());
715715
}
716-
717716
if Instant::now() >= deadline {
718-
child.kill()?;
719-
let _ = child.wait();
717+
kill_and_wait_child(child);
720718
return Err(std::io::Error::other(format!(
721719
"timed out after {SHARED_E2E_CLEANUP_TIMEOUT:?} waiting for child process"
722720
)));
@@ -726,8 +724,27 @@ fn wait_for_child_exit(child: &mut Child) -> std::io::Result<()> {
726724
}
727725

728726
fn kill_and_wait_child(child: &mut Child) {
729-
let _ = child.kill();
730-
let _ = child.wait();
727+
if let Err(error) = child.kill() {
728+
eprintln!("failed to kill E2E child process: {error}");
729+
}
730+
let deadline = Instant::now() + SHARED_E2E_CLEANUP_TIMEOUT;
731+
loop {
732+
match child.try_wait() {
733+
Ok(Some(_)) => return,
734+
Ok(None) => {}
735+
Err(error) => {
736+
eprintln!("failed to inspect E2E child process after kill: {error}");
737+
return;
738+
}
739+
}
740+
if Instant::now() >= deadline {
741+
eprintln!(
742+
"timed out after {SHARED_E2E_CLEANUP_TIMEOUT:?} waiting for killed E2E child process"
743+
);
744+
return;
745+
}
746+
std::thread::sleep(Duration::from_millis(25));
747+
}
731748
}
732749

733750
fn connect_with_timeout(host: &str, port: u16) -> std::io::Result<TcpStream> {

0 commit comments

Comments
 (0)