Skip to content

Commit

Permalink
Simplify control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
SoloJacobs committed Nov 8, 2023
1 parent 0d11c8b commit f2b21ee
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions v2/robotmk/src/bin/scheduler/child_process_supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,17 @@ impl ChildProcessSupervisor<'_> {
return Ok(ChildProcessOutcome::Terminated);
}

if let Some(exit_status) = child
.try_wait()
.context(format!(
"Failed to query exit status of process {}, killing",
child.id()
))
.map_err(|err| {
match child.try_wait() {
Ok(Some(exit_status)) => return Ok(ChildProcessOutcome::Exited(exit_status)),
Ok(None) => {}
e => {
kill_child_tree(child);
err
})?
{
return Ok(ChildProcessOutcome::Exited(exit_status));
e.context(format!(
"Failed to query exit status of process {}, killing",
child.id()
))?;
}
}

sleep(Duration::from_millis(250)).await
}
}
Expand Down

0 comments on commit f2b21ee

Please sign in to comment.