From: Ian Jackson Date: Sat, 12 Dec 2020 21:44:13 +0000 (+0000) Subject: unix ExitStatus: Provide .core_dumped X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=3f05051d6bcb7b8562577324d59a2435a40992e9;p=rust.git unix ExitStatus: Provide .core_dumped This is essential for proper reporting of child process status on Unix. Signed-off-by: Ian Jackson --- diff --git a/library/std/src/sys/unix/ext/process.rs b/library/std/src/sys/unix/ext/process.rs index 4b65629e2b3..827cc0b9828 100644 --- a/library/std/src/sys/unix/ext/process.rs +++ b/library/std/src/sys/unix/ext/process.rs @@ -176,6 +176,10 @@ pub trait ExitStatusExt { #[stable(feature = "rust1", since = "1.0.0")] fn signal(&self) -> Option; + /// 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 @@ fn signal(&self) -> Option { 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() } diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index f1cf4028057..99b1011578a 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -482,6 +482,10 @@ pub fn signal(&self) -> Option { 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 }