diff --git a/plugins/shell/src/process/mod.rs b/plugins/shell/src/process/mod.rs index ac801834..0cca55c0 100644 --- a/plugins/shell/src/process/mod.rs +++ b/plugins/shell/src/process/mod.rs @@ -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> { + 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()