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"); }