Skip to content

Commit

Permalink
just add one method named creation_flags, fix the tidy error
Browse files Browse the repository at this point in the history
  • Loading branch information
luser committed Dec 1, 2016
1 parent 8b1c4cb commit e6975e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,15 +1180,16 @@ mod tests {

extern "system" {
fn WaitForDebugEvent(lpDebugEvent: *mut DEBUG_EVENT, dwMilliseconds: DWORD) -> BOOL;
fn ContinueDebugEvent(dwProcessId: DWORD, dwThreadId: DWORD, dwContinueStatus: DWORD) -> BOOL;
fn ContinueDebugEvent(dwProcessId: DWORD, dwThreadId: DWORD,
dwContinueStatus: DWORD) -> BOOL;
}

const DEBUG_PROCESS: DWORD = 1;
const EXIT_PROCESS_DEBUG_EVENT: DWORD = 5;
const DBG_EXCEPTION_NOT_HANDLED: DWORD = 0x80010001;

let mut child = Command::new("cmd")
.add_creation_flags(DEBUG_PROCESS)
.creation_flags(DEBUG_PROCESS)
.stdin(Stdio::piped()).spawn().unwrap();
child.stdin.take().unwrap().write_all(b"exit\r\n").unwrap();
let mut events = 0;
Expand Down
16 changes: 3 additions & 13 deletions src/libstd/sys/windows/ext/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,13 @@ pub trait CommandExt {
/// 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;
fn 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);
fn creation_flags(&mut self, flags: u32) -> &mut process::Command {
self.as_inner_mut().creation_flags(flags);
self
}
}
5 changes: 1 addition & 4 deletions src/libstd/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,9 @@ impl Command {
pub fn stderr(&mut self, stderr: Stdio) {
self.stderr = Some(stderr);
}
pub fn set_creation_flags(&mut self, flags: u32) {
pub fn 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)> {
Expand Down

0 comments on commit e6975e9

Please sign in to comment.