5 unstable releases
0.3.2 | Jan 2, 2024 |
---|---|
0.3.1 | Jan 2, 2024 |
0.3.0 | Nov 15, 2023 |
0.2.0 | Nov 8, 2023 |
0.1.0 | Nov 8, 2023 |
#5 in #terminate
311 downloads per month
10KB
165 lines
tokio-process-terminate
Extensions to tokio::process::Child
to terminate processes.
use tokio::process::Command;
use tokio_process_terminate::TerminateExt;
#[tokio::main]
async fn main() {
let mut command = Command::new("sleep")
.arg("10")
.spawn()
.unwrap();
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let exit = command.terminate_wait().await.unwrap();
dbg!(exit);
let code = exit.code();
// On Unix, code should be `None` if the process was terminated by a signal.
assert!(code.is_none());
}
lib.rs
:
Extensions to tokio::process::Child
to terminate processes.
use tokio::process::Command;
use tokio_process_terminate::TerminateExt;
#[tokio::main]
async fn main() {
let mut command = Command::new("sleep")
.arg("10")
.spawn()
.unwrap();
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let exit = command.terminate_wait().await.unwrap();
dbg!(exit);
let code = exit.code();
// On Unix, code should be `None` if the process was terminated by a signal.
assert!(code.is_none());
}
Dependencies
~3–12MB
~133K SLoC