3 unstable releases

Uses old Rust 2015

0.2.0 Jun 21, 2018
0.1.2 Jun 21, 2018
0.1.1 Jun 21, 2018

#21 in #process-running


Used in 2 crates (via pgdb)

MIT license

8KB
78 lines

process_guard

A process guard takes ownership of a process::Child and gently or forcefully kills it upon, prevent the process from running on. Example:

use process_guard::ProcessGuard;
use std::process;

fn insomnia() {
   let cmd = process::Command::new("sleep").arg("120");
   let pg = ProcessGuard::spawn(cmd);

   // a two-minute sleep process has been started, which will be killed as soon as this
   // function returns
}

OS support

The crate is currently only developed with Linux in mind. Windows/BSD/Mac OS X ports are appreciated


lib.rs:

Process guard

A process guard takes ownership of a process::Child and gently or forcefully kills it upon, prevent the process from running on. Example:

use process_guard::ProcessGuard;
use std::process;

fn insomnia() {
    let pg = ProcessGuard::spawn(process::Command::new("sleep").arg("120"));

    // a two-minute sleep process has been started, which will be killed as soon as this
    // function returns
}

Dependencies

~2MB
~38K SLoC