use crate::builder::CommandGroupBuilder;
use crate::AsyncGroupChild;
impl CommandGroupBuilder<'_, tokio::process::Command> {
pub fn spawn(&mut self) -> std::io::Result<AsyncGroupChild> {
#[cfg(tokio_unstable)]
{
self.command.process_group(0);
}
#[cfg(not(tokio_unstable))]
unsafe {
use nix::unistd::{setpgid, Pid};
use std::io::Error;
self.command.pre_exec(|| {
setpgid(Pid::this(), Pid::from_raw(0))
.map_err(Error::from)
.map(|_| ())
});
}
self.command.spawn().map(AsyncGroupChild::new)
}
}