unix ExitStatus: Provide .core_dumped

This is essential for proper reporting of child process status on Unix.

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

View File

@ -176,6 +176,10 @@ pub trait ExitStatusExt {
#[stable(feature = "rust1", since = "1.0.0")]
fn signal(&self) -> Option<i32>;
/// If the process was terminated by a signal, says whether it dumped core.
#[unstable(feature = "unix_process_wait_more", issue = "none")]
fn core_dumped(&self) -> bool;
/// Returns the underlying raw `wait` status.
#[unstable(feature = "unix_process_wait_more", issue = "none")]
fn into_raw(self) -> i32;
@ -191,6 +195,10 @@ impl ExitStatusExt for process::ExitStatus {
self.as_inner().signal()
}
fn core_dumped(&self) -> bool {
self.as_inner().core_dumped()
}
fn into_raw(self) -> i32 {
self.as_inner().into_raw().into()
}

View File

@ -482,6 +482,10 @@ impl ExitStatus {
if libc::WIFSIGNALED(self.0) { Some(libc::WTERMSIG(self.0)) } else { None }
}
pub fn core_dumped(&self) -> bool {
libc::WIFSIGNALED(self.0) && libc::WCOREDUMP(self.0)
}
pub fn into_raw(&self) -> c_int {
self.0
}