process_wrap/std/
creation_flags.rs

1use std::{io::Result, os::windows::process::CommandExt, process::Command};
2
3use windows::Win32::System::Threading::PROCESS_CREATION_FLAGS;
4
5use super::{StdCommandWrap, StdCommandWrapper};
6
7/// Shim wrapper which sets Windows process creation flags.
8///
9/// This wrapper is only available on Windows.
10///
11/// It exists to be able to set creation flags on a `Command` and also store them in the wrapper, so
12/// that they're no overwritten by other wrappers. Notably this is the only way to use creation
13/// flags and the `JobObject` wrapper together.
14///
15/// When both `CreationFlags` and `JobObject` are used together, `CreationFlags` must come first.
16#[derive(Clone, Copy, Debug)]
17pub struct CreationFlags(pub PROCESS_CREATION_FLAGS);
18
19impl StdCommandWrapper for CreationFlags {
20	fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> Result<()> {
21		command.creation_flags((self.0).0);
22		Ok(())
23	}
24}