Skip to content

Commit

Permalink
clearer task termination logic
Browse files Browse the repository at this point in the history
  • Loading branch information
evmar committed Aug 29, 2023
1 parent 4ba54d1 commit 6edf153
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/process_posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,22 @@ pub fn run_command(cmdline: &str, mut output_cb: impl FnMut(&[u8])) -> anyhow::R
std::process::ExitStatus::from_raw(status)
};

let mut termination = Termination::Success;
if !status.success() {
termination = Termination::Failure;
if let Some(sig) = status.signal() {
match sig {
libc::SIGINT => {
output_cb("interrupted".as_bytes());
termination = Termination::Interrupted;
}
_ => output_cb(format!("signal {}", sig).as_bytes()),
let termination = if status.success() {
Termination::Success
} else if let Some(sig) = status.signal() {
match sig {
libc::SIGINT => {
output_cb("interrupted".as_bytes());
Termination::Interrupted
}
_ => {
output_cb(format!("signal {}", sig).as_bytes());
Termination::Failure
}
}
}
} else {
Termination::Failure
};

Ok(termination)
}

0 comments on commit 6edf153

Please sign in to comment.