From f46670400de79e496e2451fd22faf5dba63a51b7 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 31 Aug 2023 19:04:23 -0300 Subject: [PATCH] We actually need to kill the runner on timeout --- tokiocommandtimeouttest/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tokiocommandtimeouttest/src/main.rs b/tokiocommandtimeouttest/src/main.rs index 62ff0fd..928d86e 100644 --- a/tokiocommandtimeouttest/src/main.rs +++ b/tokiocommandtimeouttest/src/main.rs @@ -24,17 +24,18 @@ async fn main() { println!("Run 3 secs"); let mut cmd = Command::new(&sleep).arg("3s").spawn().unwrap(); - if let Err(_) = timeout(Duration::from_secs(4), cmd.wait()).await { println!("Got timeout!"); + cmd.kill().await.unwrap(); } else { println!("No timeout"); } - println!("Run 5 secs"); - let mut cmd = Command::new(&sleep).arg("5s").spawn().unwrap(); + println!("Run 25 secs"); + let mut cmd = Command::new(&sleep).arg("25s").spawn().unwrap(); if let Err(_) = timeout(Duration::from_secs(4), cmd.wait()).await { - println!("Got timeout") + println!("Got timeout"); + cmd.kill().await.unwrap(); } else { println!("No timeout"); }