diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-01-14 17:59:53 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-14 17:59:53 +0000 |
| commit | 8ac21fb201bc374fe958a0a98150c2c8d2c798db (patch) | |
| tree | af6fa8d3865848ae875417f39404f36c16e1ab93 /library/std/src/sys/unix/process/process_unix.rs | |
| parent | d03fe84169d50a4b96cdef7b2f862217ab634055 (diff) | |
| parent | a8d01619608715e6abc4c6d3c6f347f393262725 (diff) | |
| download | rust-8ac21fb201bc374fe958a0a98150c2c8d2c798db.tar.gz rust-8ac21fb201bc374fe958a0a98150c2c8d2c798db.zip | |
Rollup merge of #79982 - ijackson:exit-status, r=dtolnay
Add missing methods to unix ExitStatusExt These are the methods corresponding to the remaining exit status examination macros from `wait.h`. `WCOREDUMP` isn't in SuS but is it is very standard. I have not done portability testing to see if this builds everywhere, so I may need to Do Something if it doesn't. There is also a bugfix and doc improvement to `.signal()`, and an `.into_raw()` accessor. This would fix #73128 and fix #73129. Please let me know if you like this direction, and if so I will open the tracking issue and so on. If this MR goes well, I may tackle #73125 next - I have an idea for how to do it.
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index a590c744356..945b43678a9 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -479,7 +479,23 @@ impl ExitStatus { } pub fn signal(&self) -> Option<i32> { - if !self.exited() { Some(libc::WTERMSIG(self.0)) } else { None } + if libc::WIFSIGNALED(self.0) { Some(libc::WTERMSIG(self.0)) } else { None } + } + + pub fn core_dumped(&self) -> bool { + 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 continued(&self) -> bool { + libc::WIFCONTINUED(self.0) + } + + pub fn into_raw(&self) -> c_int { + self.0 } } |
