]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys/unix/process/process_unix.rs
process::unix: Handle other wait statuses in ExitStatus as Display
[rust.git] / library / std / src / sys / unix / process / process_unix.rs
index 9e82df7755e89c5d58240e4ddee91ac122c0aad1..26cbb0a5083181e6442a07529f57df41a9abcfc4 100644 (file)
@@ -527,9 +527,18 @@ 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)
         }
     }
 }