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

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

#5 in #terminate

Download history 40/week @ 2024-07-22 82/week @ 2024-07-29 1/week @ 2024-08-05 7/week @ 2024-08-12 16/week @ 2024-08-19 50/week @ 2024-08-26 24/week @ 2024-09-02 62/week @ 2024-09-09 53/week @ 2024-09-16 30/week @ 2024-09-23 38/week @ 2024-09-30 117/week @ 2024-10-07 97/week @ 2024-10-14 102/week @ 2024-10-21 62/week @ 2024-10-28 46/week @ 2024-11-04

311 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
~133K SLoC