diff options
| author | Ted Mielczarek <ted@mielczarek.org> | 2016-11-30 19:44:07 -0500 |
|---|---|---|
| committer | Ted Mielczarek <ted@mielczarek.org> | 2016-11-30 19:44:07 -0500 |
| commit | 8b1c4cbbaf0252ed68f62b0613a8da9725141262 (patch) | |
| tree | df1d9c922a8f689eb0a06093ee4e7408fd10dbb5 /src/libstd/sys/windows/process.rs | |
| parent | 127a83df6615d09cda6ed9b53f7daba2d78c925d (diff) | |
| download | rust-8b1c4cbbaf0252ed68f62b0613a8da9725141262.tar.gz rust-8b1c4cbbaf0252ed68f62b0613a8da9725141262.zip | |
Add std::os::windows::process::CommandExt, with set_creation_flags and add_creation_flags methods. Fixes #37827
This adds a CommandExt trait for Windows along with an implementation of it for std::process::Command with methods to set the process creation flags that are passed to CreateProcess.
Diffstat (limited to 'src/libstd/sys/windows/process.rs')
| -rw-r--r-- | src/libstd/sys/windows/process.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index d371714ff0e..a221c67efd9 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -54,6 +54,7 @@ pub struct Command { args: Vec<OsString>, env: Option<HashMap<OsString, OsString>>, cwd: Option<OsString>, + flags: u32, detach: bool, // not currently exposed in std::process stdin: Option<Stdio>, stdout: Option<Stdio>, @@ -84,6 +85,7 @@ impl Command { args: Vec::new(), env: None, cwd: None, + flags: 0, detach: false, stdin: None, stdout: None, @@ -124,6 +126,12 @@ impl Command { pub fn stderr(&mut self, stderr: Stdio) { self.stderr = Some(stderr); } + pub fn set_creation_flags(&mut self, flags: u32) { + self.flags = flags; + } + pub fn add_creation_flags(&mut self, flags: u32) { + self.flags = self.flags | flags; + } pub fn spawn(&mut self, default: Stdio, needs_stdin: bool) -> io::Result<(Process, StdioPipes)> { @@ -157,7 +165,7 @@ impl Command { cmd_str.push(0); // add null terminator // stolen from the libuv code. - let mut flags = c::CREATE_UNICODE_ENVIRONMENT; + let mut flags = self.flags | c::CREATE_UNICODE_ENVIRONMENT; if self.detach { flags |= c::DETACHED_PROCESS | c::CREATE_NEW_PROCESS_GROUP; } |
