From 530270f94a3d9f1c23257ad1c9c93675b31ecf6a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 12 Dec 2020 21:41:55 +0000 Subject: [PATCH] unix ExitStatus: Provide .into_raw() Signed-off-by: Ian Jackson --- library/std/src/sys/unix/ext/process.rs | 8 ++++++++ library/std/src/sys/unix/process/process_unix.rs | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/library/std/src/sys/unix/ext/process.rs b/library/std/src/sys/unix/ext/process.rs index ab961a284d5..4b65629e2b3 100644 --- a/library/std/src/sys/unix/ext/process.rs +++ b/library/std/src/sys/unix/ext/process.rs @@ -175,6 +175,10 @@ pub trait ExitStatusExt { /// Ie, if `WIFSIGNALED`, this returns `WTERMSIG`. #[stable(feature = "rust1", since = "1.0.0")] fn signal(&self) -> Option; + + /// Returns the underlying raw `wait` status. + #[unstable(feature = "unix_process_wait_more", issue = "none")] + fn into_raw(self) -> i32; } #[stable(feature = "rust1", since = "1.0.0")] @@ -186,6 +190,10 @@ impl ExitStatusExt for process::ExitStatus { fn signal(&self) -> Option { self.as_inner().signal() } + + fn into_raw(self) -> i32 { + self.as_inner().into_raw().into() + } } #[stable(feature = "process_extensions", since = "1.2.0")] diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 629180fd712..f1cf4028057 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -481,6 +481,10 @@ impl ExitStatus { pub fn signal(&self) -> Option { if libc::WIFSIGNALED(self.0) { Some(libc::WTERMSIG(self.0)) } else { None } } + + pub fn into_raw(&self) -> c_int { + self.0 + } } /// Converts a raw `c_int` to a type-safe `ExitStatus` by wrapping it without copying.