]> git.lizzy.rs Git - rust.git/commitdiff
unix ExitStatus: Provide .core_dumped
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 12 Dec 2020 21:44:13 +0000 (21:44 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Jan 2021 12:50:29 +0000 (12:50 +0000)
This is essential for proper reporting of child process status on Unix.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
library/std/src/sys/unix/ext/process.rs
library/std/src/sys/unix/process/process_unix.rs

index 4b65629e2b3688902d57345e1f7881795c4335bd..827cc0b9828b4537cc35de12862ca2682c8e5891 100644 (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 @@ fn signal(&self) -> Option<i32> {
         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()
     }
index f1cf402805781306e89187e98de435184d70300b..99b1011578a5abaee6a5325fe012a4c10c4c8b45 100644 (file)
@@ -482,6 +482,10 @@ pub fn signal(&self) -> Option<i32> {
         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
     }