diff options
| author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2020-12-12 21:44:13 +0000 |
|---|---|---|
| committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2021-01-13 12:50:29 +0000 |
| commit | 3f05051d6bcb7b8562577324d59a2435a40992e9 (patch) | |
| tree | 2669f529d798fce7d9aa246d605c0e091287f264 | |
| parent | 530270f94a3d9f1c23257ad1c9c93675b31ecf6a (diff) | |
| download | rust-3f05051d6bcb7b8562577324d59a2435a40992e9.tar.gz rust-3f05051d6bcb7b8562577324d59a2435a40992e9.zip | |
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>
| -rw-r--r-- | library/std/src/sys/unix/ext/process.rs | 8 | ||||
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 4 |
2 files changed, 12 insertions, 0 deletions
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<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() } 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 @@ 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 } |
