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/ext | |
| 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/ext')
| -rw-r--r-- | src/libstd/sys/windows/ext/process.rs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/libstd/sys/windows/ext/process.rs b/src/libstd/sys/windows/ext/process.rs index bce32959a23..f5bf3354637 100644 --- a/src/libstd/sys/windows/ext/process.rs +++ b/src/libstd/sys/windows/ext/process.rs @@ -15,7 +15,7 @@ use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle}; use process; use sys; -use sys_common::{AsInner, FromInner, IntoInner}; +use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; #[stable(feature = "process_extensions", since = "1.2.0")] impl FromRawHandle for process::Stdio { @@ -97,3 +97,32 @@ impl ExitStatusExt for process::ExitStatus { process::ExitStatus::from_inner(From::from(raw)) } } + +/// Windows-specific extensions to the `std::process::Command` builder +#[unstable(feature = "windows_process_extensions", issue = "37827")] +pub trait CommandExt { + /// Sets the [process creation flags][1] to be passed to `CreateProcess`. + /// + /// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`. + /// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx + #[unstable(feature = "windows_process_extensions", issue = "37827")] + fn set_creation_flags(&mut self, flags: u32) -> &mut process::Command; + /// Add `flags` to the the [process creation flags][1] to be passed to `CreateProcess`. + /// + /// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`. + /// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx + #[unstable(feature = "windows_process_extensions", issue = "37827")] + fn add_creation_flags(&mut self, flags: u32) -> &mut process::Command; +} + +#[unstable(feature = "windows_process_extensions", issue = "37827")] +impl CommandExt for process::Command { + fn set_creation_flags(&mut self, flags: u32) -> &mut process::Command { + self.as_inner_mut().set_creation_flags(flags); + self + } + fn add_creation_flags(&mut self, flags: u32) -> &mut process::Command { + self.as_inner_mut().add_creation_flags(flags); + self + } +} |
