about summary refs log tree commit diff
path: root/src/libstd/process.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-19 19:20:20 +0000
committerbors <bors@rust-lang.org>2015-05-19 19:20:20 +0000
commitf34ff7af7362053e8aee7a35365d6320ed6e88b8 (patch)
tree743382e396ca1b5e133b11f313febc9421ed4780 /src/libstd/process.rs
parentaca207a65c82d7581076772846ef424f1a64449b (diff)
parent1ec7a697328fb10e7135b87557ff0a5ea702dd8d (diff)
downloadrust-f34ff7af7362053e8aee7a35365d6320ed6e88b8.tar.gz
rust-f34ff7af7362053e8aee7a35365d6320ed6e88b8.zip
Auto merge of #25495 - alexcrichton:process-pid, r=aturon
This commits adds a method to the `std::process` module to get the process
identifier of the child as a `u32`. On Windows the underlying identifier is
already a `u32`, and on Unix the type is typically defined as `c_int` (`i32` for
almost all our supported platforms), but the actually pid is normally a small
positive number.

Eventually we may add functions to load information about a process based on its
identifier or the ability to terminate a process based on its identifier, but
for now this function should enable this sort of functionality to exist outside
the standard library.
Diffstat (limited to 'src/libstd/process.rs')
-rw-r--r--src/libstd/process.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index 61398e16ba0..ae9316ddd62 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -456,6 +456,12 @@ impl Child {
         unsafe { self.handle.kill() }
     }
 
+    /// Returns the OS-assigned process identifier associated with this child.
+    #[unstable(feature = "process_id", reason = "api recently added")]
+    pub fn id(&self) -> u32 {
+        self.handle.id()
+    }
+
     /// Waits for the child to exit completely, returning the status that it
     /// exited with. This function will continue to have the same return value
     /// after it has been called at least once.