feat(shell): add exit_status to get the child's exit status.

pull/2224/head
Chaoqian Xu 7 months ago
parent 882ea43183
commit 126f5f4da7

@ -80,6 +80,13 @@ impl CommandChild {
Ok(()) 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. /// Returns the process pid.
pub fn pid(&self) -> u32 { pub fn pid(&self) -> u32 {
self.inner.id() self.inner.id()

Loading…
Cancel
Save