Skip to content

Commit 3f05051

Browse files
committed
unix ExitStatus: Provide .core_dumped
This is essential for proper reporting of child process status on Unix. Signed-off-by: Ian Jackson <[email protected]>
1 parent 530270f commit 3f05051

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

library/std/src/sys/unix/ext/process.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ pub trait ExitStatusExt {
176176
#[stable(feature = "rust1", since = "1.0.0")]
177177
fn signal(&self) -> Option<i32>;
178178

179+
/// If the process was terminated by a signal, says whether it dumped core.
180+
#[unstable(feature = "unix_process_wait_more", issue = "none")]
181+
fn core_dumped(&self) -> bool;
182+
179183
/// Returns the underlying raw `wait` status.
180184
#[unstable(feature = "unix_process_wait_more", issue = "none")]
181185
fn into_raw(self) -> i32;
@@ -191,6 +195,10 @@ impl ExitStatusExt for process::ExitStatus {
191195
self.as_inner().signal()
192196
}
193197

198+
fn core_dumped(&self) -> bool {
199+
self.as_inner().core_dumped()
200+
}
201+
194202
fn into_raw(self) -> i32 {
195203
self.as_inner().into_raw().into()
196204
}

library/std/src/sys/unix/process/process_unix.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ impl ExitStatus {
482482
if libc::WIFSIGNALED(self.0) { Some(libc::WTERMSIG(self.0)) } else { None }
483483
}
484484

485+
pub fn core_dumped(&self) -> bool {
486+
libc::WIFSIGNALED(self.0) && libc::WCOREDUMP(self.0)
487+
}
488+
485489
pub fn into_raw(&self) -> c_int {
486490
self.0
487491
}

0 commit comments

Comments
 (0)