use std::io::Result;
use tokio::process::Command;
use windows::Win32::System::Threading::PROCESS_CREATION_FLAGS;
use super::{CommandWrap, CommandWrapper};
#[cfg(feature = "job-object")]
use super::JobObject;
#[cfg(feature = "job-object")]
use crate::windows::job_creation_flags;
#[derive(Clone, Copy, Debug)]
pub struct CreationFlags(pub PROCESS_CREATION_FLAGS);
impl CommandWrapper for CreationFlags {
fn pre_spawn(&mut self, command: &mut Command, core: &CommandWrap) -> Result<()> {
#[cfg(feature = "job-object")]
let flags = if core.has_wrap::<JobObject>() {
job_creation_flags(self.0).flags
} else {
self.0
};
#[cfg(not(feature = "job-object"))]
let flags = {
let _ = core;
self.0
};
command.creation_flags(flags.0);
Ok(())
}
}