about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/unix/ext/process.rs11
-rw-r--r--library/std/src/sys/unix/process/process_unix.rs4
2 files changed, 15 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/ext/process.rs b/library/std/src/sys/unix/ext/process.rs
index 827cc0b9828..5efe08340f4 100644
--- a/library/std/src/sys/unix/ext/process.rs
+++ b/library/std/src/sys/unix/ext/process.rs
@@ -180,6 +180,13 @@ pub trait ExitStatusExt {
     #[unstable(feature = "unix_process_wait_more", issue = "none")]
     fn core_dumped(&self) -> bool;
 
+    /// If the process was stopped by a signal, returns that signal.
+    ///
+    /// Ie, if `WIFSTOPPED`, this returns `WSTOPSIG`.  This is only possible if the status came from
+    /// a `wait` system call which was passed `WUNTRACED`, was then converted into an `ExitStatus`.
+    #[unstable(feature = "unix_process_wait_more", issue = "none")]
+    fn stopped_signal(&self) -> Option<i32>;
+
     /// Returns the underlying raw `wait` status.
     #[unstable(feature = "unix_process_wait_more", issue = "none")]
     fn into_raw(self) -> i32;
@@ -199,6 +206,10 @@ impl ExitStatusExt for process::ExitStatus {
         self.as_inner().core_dumped()
     }
 
+    fn stopped_signal(&self) -> Option<i32> {
+        self.as_inner().stopped_signal()
+    }
+
     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 99b1011578a..069a1145f76 100644
--- a/library/std/src/sys/unix/process/process_unix.rs
+++ b/library/std/src/sys/unix/process/process_unix.rs
@@ -486,6 +486,10 @@ impl ExitStatus {
         libc::WIFSIGNALED(self.0) && libc::WCOREDUMP(self.0)
     }
 
+    pub fn stopped_signal(&self) -> Option<i32> {
+        if libc::WIFSTOPPED(self.0) { Some(libc::WSTOPSIG(self.0)) } else { None }
+    }
+
     pub fn into_raw(&self) -> c_int {
         self.0
     }