-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add std::os::windows::process::CommandExt. Fixes #37827 #38098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In terms of naming and functionality I think we'll want to follow the same pattern as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had originally written it that way, but I worried about flexibility--it'd mean you couldn't attempt to set the creation flags in more than one place, since the last call would override. Perhaps I'm overthinking it? I suppose it's unlikely you'd be able to set creation flags from a library function in a useful manner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I renamed it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yeah plural sounds good to me, and it's a good point about working with libraries. I'll add this as a concern to the tracking issue |
||
} | ||
|
||
#[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 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think tidy is complaining about this line being over 100 chars