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#[derive(Clone, Copy, Debug)]
15pub struct CreationFlags(pub PROCESS_CREATION_FLAGS);
16
17impl StdCommandWrapper for CreationFlags {
18	fn pre_spawn(&mut self, command: &mut Command, _core: &StdCommandWrap) -> Result<()> {
19		command.creation_flags((self.0).0);
20		Ok(())
21	}
22}