unix ExitStatus: Provide .into_raw()

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This commit is contained in:
Ian Jackson 2020-12-12 21:41:55 +00:00
parent 12d62aa436
commit 530270f94a
2 changed files with 12 additions and 0 deletions

View File

@ -175,6 +175,10 @@ pub trait ExitStatusExt {
/// Ie, if `WIFSIGNALED`, this returns `WTERMSIG`.
#[stable(feature = "rust1", since = "1.0.0")]
fn signal(&self) -> Option<i32>;
/// 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<i32> {
self.as_inner().signal()
}
fn into_raw(self) -> i32 {
self.as_inner().into_raw().into()
}
}
#[stable(feature = "process_extensions", since = "1.2.0")]

View File

@ -481,6 +481,10 @@ impl ExitStatus {
pub fn signal(&self) -> Option<i32> {
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.