tokio-process-terminate

Crates.iotokio-process-terminate
lib.rstokio-process-terminate
version0.3.2
sourcesrc
created_at2023-11-08 07:45:46.922265
updated_at2024-01-02 11:18:20.453544
descriptionA tokio process extension to terminate child processes
homepagehttps://github.com/zitsen/tokio-process-terminate
repositoryhttps://github.com/zitsen/tokio-process-terminate.git
max_upload_size
id1028828
size14,057
Linhe Huo (zitsen)

documentation

README

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());
}
Commit count: 11

cargo fmt