#child-process #process #tokio #terminate #ctrl-c

tokio-process-terminate

A tokio process extension to terminate child processes

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

#6 in #ctrl-c

Download history 27/week @ 2024-06-13 102/week @ 2024-06-20 86/week @ 2024-06-27 46/week @ 2024-07-04 3/week @ 2024-07-11 35/week @ 2024-07-18 80/week @ 2024-07-25 22/week @ 2024-08-01 7/week @ 2024-08-08 9/week @ 2024-08-15 41/week @ 2024-08-22 33/week @ 2024-08-29 34/week @ 2024-09-05 66/week @ 2024-09-12 36/week @ 2024-09-19 21/week @ 2024-09-26

161 downloads per month

MIT/Apache

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
~131K SLoC