1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
use std::{
io::{Error, Result},
os::unix::process::CommandExt,
process::Command,
};
use crate::{CommandGroup, GroupChild};
use nix::unistd::setsid;
impl CommandGroup for Command {
fn group_spawn(&mut self) -> Result<GroupChild> {
unsafe {
self.pre_exec(|| setsid().map_err(Error::from).map(|_| ()));
}
self.spawn().map(GroupChild::new)
}
}