Crates.io | process_guard |
lib.rs | process_guard |
version | 0.2.0 |
source | src |
created_at | 2018-06-21 17:10:25.439358 |
updated_at | 2018-06-21 18:57:50.596591 |
description | Guard a process by terminating it on drop |
homepage | |
repository | https://github.com/49nord/process_guard-rs |
max_upload_size | |
id | 71112 |
size | 7,617 |
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
}
The crate is currently only developed with Linux in mind. Windows/BSD/Mac OS X ports are appreciated