Trait command_group::UnixChildExt
source · pub trait UnixChildExt {
// Required method
fn signal(&self, sig: Signal) -> Result<()>;
}
Expand description
Unix-specific extensions to process Child
ren.
Required Methods§
sourcefn signal(&self, sig: Signal) -> Result<()>
fn signal(&self, sig: Signal) -> Result<()>
Sends a signal to the child process. If the process has already exited, an InvalidInput
error is returned.
Examples
Basic usage:
use std::process::Command;
use command_group::{UnixChildExt, Signal};
let mut command = Command::new("yes");
if let Ok(mut child) = command.spawn() {
child.signal(Signal::SIGTERM).expect("command wasn't running");
} else {
println!("yes command didn't start");
}
With a process group:
use std::process::Command;
use command_group::{CommandGroup, UnixChildExt, Signal};
let mut command = Command::new("yes");
if let Ok(mut child) = command.group_spawn() {
child.signal(Signal::SIGTERM).expect("command wasn't running");
} else {
println!("yes command didn't start");
}