use std::process::{Child, Command};
pub struct GuardedCommand(Child);
impl GuardedCommand {
pub fn spawn(mut command: Command) -> GuardedCommand {
GuardedCommand(command.spawn().expect("failed to execute child command"))
}
}
impl Drop for GuardedCommand {
fn drop(&mut self) {
if let Err(e) = self.0.kill() {
panic!("Failed to kill child process: {:?}", e);
}
}
}