|
15 | 15 | use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle};
|
16 | 16 | use process;
|
17 | 17 | use sys;
|
18 |
| -use sys_common::{AsInner, FromInner, IntoInner}; |
| 18 | +use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; |
19 | 19 |
|
20 | 20 | #[stable(feature = "process_extensions", since = "1.2.0")]
|
21 | 21 | impl FromRawHandle for process::Stdio {
|
@@ -97,3 +97,32 @@ impl ExitStatusExt for process::ExitStatus {
|
97 | 97 | process::ExitStatus::from_inner(From::from(raw))
|
98 | 98 | }
|
99 | 99 | }
|
| 100 | + |
| 101 | +/// Windows-specific extensions to the `std::process::Command` builder |
| 102 | +#[unstable(feature = "windows_process_extensions", issue = "37827")] |
| 103 | +pub trait CommandExt { |
| 104 | + /// Sets the [process creation flags][1] to be passed to `CreateProcess`. |
| 105 | + /// |
| 106 | + /// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`. |
| 107 | + /// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx |
| 108 | + #[unstable(feature = "windows_process_extensions", issue = "37827")] |
| 109 | + fn set_creation_flags(&mut self, flags: u32) -> &mut process::Command; |
| 110 | + /// Add `flags` to the the [process creation flags][1] to be passed to `CreateProcess`. |
| 111 | + /// |
| 112 | + /// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`. |
| 113 | + /// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx |
| 114 | + #[unstable(feature = "windows_process_extensions", issue = "37827")] |
| 115 | + fn add_creation_flags(&mut self, flags: u32) -> &mut process::Command; |
| 116 | +} |
| 117 | + |
| 118 | +#[unstable(feature = "windows_process_extensions", issue = "37827")] |
| 119 | +impl CommandExt for process::Command { |
| 120 | + fn set_creation_flags(&mut self, flags: u32) -> &mut process::Command { |
| 121 | + self.as_inner_mut().set_creation_flags(flags); |
| 122 | + self |
| 123 | + } |
| 124 | + fn add_creation_flags(&mut self, flags: u32) -> &mut process::Command { |
| 125 | + self.as_inner_mut().add_creation_flags(flags); |
| 126 | + self |
| 127 | + } |
| 128 | +} |
0 commit comments