#[cfg(unix)]
fn main() -> std::io::Result<()> {
use subprocess::unix::JobExt;
use subprocess::{Exec, ExecExt};
let handle = Exec::cmd("sleep").arg("100").start()?;
println!("Started sleep with PID {}", handle.pid());
handle.send_signal(libc::SIGTERM)?;
println!("Sent SIGTERM");
let handle = Exec::cmd("sleep").arg("100").setpgid().start()?;
println!("\nStarted sleep in new process group, PID {}", handle.pid());
handle.send_signal_group(libc::SIGKILL)?;
println!("Sent SIGKILL to process group");
let handle = Exec::cmd("sleep").arg("100").start()?;
println!("\nStarted another sleep, PID {}", handle.pid());
handle.terminate()?;
let status = handle.wait()?;
println!("After terminate: {:?}", status);
let handle = Exec::cmd("sleep").arg("100").start()?;
println!("\nStarted another sleep, PID {}", handle.pid());
handle.kill()?;
let status = handle.wait()?;
println!("After kill: {:?}", status);
Ok(())
}
#[cfg(not(unix))]
fn main() {
println!("This example only runs on Unix systems.");
}