pub trait UnixChildExt {
// Required method
fn signal(&self, sig: Signal) -> Result<()>;
}Expand description
Unix-specific extensions to process Children.
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");
}Implementations on Foreign Types§
Source§impl UnixChildExt for Child
Available on crate feature with-tokio only.
impl UnixChildExt for Child
Available on crate feature
with-tokio only.Implementors§
impl UnixChildExt for AsyncGroupChild
Available on Unix only.
impl UnixChildExt for GroupChild
Available on Unix only.