unix ExitStatus: Provide .stopped_signal()
Necessary to handle WIFSTOPPED. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This commit is contained in:
parent
3f05051d6b
commit
f060b9e0d9
@ -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()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user