diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-03-10 08:01:27 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-10 08:01:27 +0900 |
| commit | 74e74e9df88d34cf4077afcaac9321cf5eb1a58d (patch) | |
| tree | 0041741f8e77641978715c0d2d1e502e88be4326 /library/std/src/sys/unix/process/process_unix.rs | |
| parent | c46f948a8056c9da728969dcc30e4c132d4b4bbb (diff) | |
| parent | 11ca64401a5d562898e8b5f46bd36d6d1c6dc3ef (diff) | |
| download | rust-74e74e9df88d34cf4077afcaac9321cf5eb1a58d.tar.gz rust-74e74e9df88d34cf4077afcaac9321cf5eb1a58d.zip | |
Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnay
Fixes to ExitStatus and its docs * On Unix, properly display every possible wait status (and don't panic on weird values) * In the documentation, be clear and consistent about "exit status" vs "wait status".
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 2746f87468d..2fdbabae277 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -527,9 +527,22 @@ impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { write!(f, "exit code: {}", code) + } else if let Some(signal) = self.signal() { + if self.core_dumped() { + write!(f, "signal: {} (core dumped)", signal) + } else { + write!(f, "signal: {}", signal) + } + } else if let Some(signal) = self.stopped_signal() { + write!(f, "stopped (not terminated) by signal: {}", signal) + } else if self.continued() { + write!(f, "continued (WIFCONTINUED)") } else { - let signal = self.signal().unwrap(); - write!(f, "signal: {}", signal) + write!(f, "unrecognised wait status: {} {:#x}", self.0, self.0) } } } + +#[cfg(test)] +#[path = "process_unix/tests.rs"] +mod tests; |
