Skip to content

Commit

Permalink
feat(shell): add exit_status to get the child's exit status.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuchaoqian committed Dec 19, 2024
1 parent 882ea43 commit 126f5f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/shell/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ impl CommandChild {
Ok(())
}

/// Return the child's exit status if it has already exited. If the child is
/// still running, return `Ok(None)`.
pub fn exit_status(&self) -> crate::Result<Option<ExitStatus>> {
let status = self.inner.try_wait()?;
Ok(status.map(|s| ExitStatus { code: s.code() }))
}

/// Returns the process pid.
pub fn pid(&self) -> u32 {
self.inner.id()
Expand Down

0 comments on commit 126f5f4

Please sign in to comment.