about summary refs log tree commit diff
path: root/src/libstd/sys/unix/ext/process.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-04-26 15:23:46 -0700
committerAlex Crichton <alex@alexcrichton.com>2016-04-26 23:35:59 -0700
commit7f09b1f6a64339370440025d50d0ad4a7f239734 (patch)
tree48c65ea79997aa1193467936a1ecadd5091a317d /src/libstd/sys/unix/ext/process.rs
parent092b0738b7f00740c997a3fb99dd0b8b50c4c157 (diff)
downloadrust-7f09b1f6a64339370440025d50d0ad4a7f239734.tar.gz
rust-7f09b1f6a64339370440025d50d0ad4a7f239734.zip
std: Allow creating ExitStatus from raw values
Sometimes a process may be waited on externally from the standard library, in
which case it can be useful to create a raw `ExitStatus` structure to return.
This commit extends the existing Unix `ExitStatusExt` extension trait and adds a
new Windows-specific `ExitStatusExt` extension trait to do this. The methods are
currently called `ExitStatus::from_raw`.

cc #32713
Diffstat (limited to 'src/libstd/sys/unix/ext/process.rs')
-rw-r--r--src/libstd/sys/unix/ext/process.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs
index 7f31cf9f3bf..b0fed2f4694 100644
--- a/src/libstd/sys/unix/ext/process.rs
+++ b/src/libstd/sys/unix/ext/process.rs
@@ -132,6 +132,11 @@ impl CommandExt for process::Command {
 /// Unix-specific extensions to `std::process::ExitStatus`
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait ExitStatusExt {
+    /// Creates a new `ExitStatus` from the raw underlying `i32` return value of
+    /// a process.
+    #[unstable(feature = "exit_status_from", issue = "32713")]
+    fn from_raw(raw: i32) -> Self;
+
     /// If the process was terminated by a signal, returns that signal.
     #[stable(feature = "rust1", since = "1.0.0")]
     fn signal(&self) -> Option<i32>;
@@ -139,6 +144,10 @@ pub trait ExitStatusExt {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl ExitStatusExt for process::ExitStatus {
+    fn from_raw(raw: i32) -> Self {
+        process::ExitStatus::from_inner(From::from(raw))
+    }
+
     fn signal(&self) -> Option<i32> {
         self.as_inner().signal()
     }