use std::{
os::windows::{io::AsRawHandle, process::CommandExt},
process::Command,
};
use winapi::um::winbase::CREATE_SUSPENDED;
use crate::{builder::CommandGroupBuilder, winres::*, GroupChild};
impl CommandGroupBuilder<'_, Command> {
pub fn spawn(&mut self) -> std::io::Result<GroupChild> {
self.command
.creation_flags(self.creation_flags | CREATE_SUSPENDED);
let (job, completion_port) = job_object(self.kill_on_drop)?;
let child = self.command.spawn()?;
assign_child(child.as_raw_handle(), job)?;
Ok(GroupChild::new(child, job, completion_port))
}
}