process_wrap/tokio/
creation_flags.rs

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