process.rs.html -- source
Description: Source to the Rust file `libstd/sys/windows/ext/process.rs`.
Keywords: rust, rustlang, rust-lang

      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123

    // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
    // file at the top-level directory of this distribution and at
    // http://rust-lang.org/COPYRIGHT.
    //
    // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
    // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
    // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
    // option. This file may not be copied, modified, or distributed
    // except according to those terms.

    //! Extensions to `std::process` for Windows.

    #![stable(feature = "process_extensions", since = "1.2.0")]

    use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle};
    use process;
    use sys;
    use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};

    #[stable(feature = "process_extensions", since = "1.2.0")]
    impl FromRawHandle for process::Stdio {
        unsafe fn from_raw_handle(handle: RawHandle) -> process::Stdio {
            let handle = sys::handle::Handle::new(handle as *mut _);
            let io = sys::process::Stdio::Handle(handle);
            process::Stdio::from_inner(io)
        }
    }

    #[stable(feature = "process_extensions", since = "1.2.0")]
    impl AsRawHandle for process::Child {
        fn as_raw_handle(&self) -> RawHandle {
            self.as_inner().handle().raw() as *mut _
        }
    }

    #[stable(feature = "into_raw_os", since = "1.4.0")]
    impl IntoRawHandle for process::Child {
        fn into_raw_handle(self) -> RawHandle {
            self.into_inner().into_handle().into_raw() as *mut _
        }
    }

    #[stable(feature = "process_extensions", since = "1.2.0")]
    impl AsRawHandle for process::ChildStdin {
        fn as_raw_handle(&self) -> RawHandle {
            self.as_inner().handle().raw() as *mut _
        }
    }

    #[stable(feature = "process_extensions", since = "1.2.0")]
    impl AsRawHandle for process::ChildStdout {
        fn as_raw_handle(&self) -> RawHandle {
            self.as_inner().handle().raw() as *mut _
        }
    }

    #[stable(feature = "process_extensions", since = "1.2.0")]
    impl AsRawHandle for process::ChildStderr {
        fn as_raw_handle(&self) -> RawHandle {
            self.as_inner().handle().raw() as *mut _
        }
    }

    #[stable(feature = "into_raw_os", since = "1.4.0")]
    impl IntoRawHandle for process::ChildStdin {
        fn into_raw_handle(self) -> RawHandle {
            self.into_inner().into_handle().into_raw() as *mut _
        }
    }

    #[stable(feature = "into_raw_os", since = "1.4.0")]
    impl IntoRawHandle for process::ChildStdout {
        fn into_raw_handle(self) -> RawHandle {
            self.into_inner().into_handle().into_raw() as *mut _
        }
    }

    #[stable(feature = "into_raw_os", since = "1.4.0")]
    impl IntoRawHandle for process::ChildStderr {
        fn into_raw_handle(self) -> RawHandle {
            self.into_inner().into_handle().into_raw() as *mut _
        }
    }

    /// Windows-specific extensions to [`process::ExitStatus`].
    ///
    /// [`process::ExitStatus`]: ../../../../std/process/struct.ExitStatus.html
    #[stable(feature = "exit_status_from", since = "1.12.0")]
    pub trait ExitStatusExt {
        /// Creates a new `ExitStatus` from the raw underlying `u32` return value of
        /// a process.
        #[stable(feature = "exit_status_from", since = "1.12.0")]
        fn from_raw(raw: u32) -> Self;
    }

    #[stable(feature = "exit_status_from", since = "1.12.0")]
    impl ExitStatusExt for process::ExitStatus {
        fn from_raw(raw: u32) -> Self {
            process::ExitStatus::from_inner(From::from(raw))
        }
    }

    /// Windows-specific extensions to the [`process::Command`] builder.
    ///
    /// [`process::Command`]: ../../../../std/process/struct.Command.html
    #[stable(feature = "windows_process_extensions", since = "1.16.0")]
    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
        #[stable(feature = "windows_process_extensions", since = "1.16.0")]
        fn creation_flags(&mut self, flags: u32) -> &mut process::Command;
    }

    #[stable(feature = "windows_process_extensions", since = "1.16.0")]
    impl CommandExt for process::Command {
        fn creation_flags(&mut self, flags: u32) -> &mut process::Command {
            self.as_inner_mut().creation_flags(flags);
            self
        }
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)