Skip to content

Commit a34c8d6

Browse files
committed
isolate and handle unix error
Signed-off-by: Aminu 'Seun Joshua <[email protected]>
1 parent 36a4fcc commit a34c8d6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/subprocess.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::os::unix::process::ExitStatusExt as _;
2+
13
/// An error representing a subprocess that errored
24
///
35
/// This can be used to propogate a subprocesses exit status.
@@ -9,12 +11,20 @@ pub struct ExitStatusError {
911
}
1012

1113
impl ExitStatusError {
14+
#[cfg(windows)]
1215
pub(crate) fn new(status: std::process::ExitStatus) -> Self {
1316
Self {
1417
status: status.code(),
1518
}
1619
}
1720

21+
#[cfg(unix)]
22+
pub(crate) fn new(status: std::process::ExitStatus) -> Self {
23+
Self {
24+
status: status.code().or_else(|| status.signal()),
25+
}
26+
}
27+
1828
pub fn code(&self) -> i32 {
1929
self.status.unwrap_or(1)
2030
}

0 commit comments

Comments
 (0)