pub struct Child {
pub stdin: Option<ChildStdin>,
pub stdout: Option<ChildStdout>,
pub stderr: Option<ChildStderr>,
/* private fields */
}Expand description
A spawned child process.
Fields§
§stdin: Option<ChildStdin>The child’s stdin, if piped.
stdout: Option<ChildStdout>The child’s stdout, if piped.
stderr: Option<ChildStderr>The child’s stderr, if piped.
Implementations§
Source§impl Child
impl Child
Sourcepub async fn wait(&mut self) -> Result<ExitStatus>
pub async fn wait(&mut self) -> Result<ExitStatus>
Waits for the child’s exit. Its stdin, if piped, is closed first, so a child that reads it to its end can exit.
§Errors
When the exit cannot be watched, or the child was reaped by
something else (ECHILD: SIGCHLD ignored, or a waitpid of the
program’s own).
Sourcepub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
pub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
The child’s status if it exited, else None, without waiting.
§Errors
When the child’s state cannot be read.
Sourcepub fn start_kill(&mut self) -> Result<()>
pub fn start_kill(&mut self) -> Result<()>
Starts ending the child, without waiting for it to go: SIGKILL on
unix, TerminateProcess on Windows. A child that exited already is
left alone.
§Errors
When the signal or the call fails.
Sourcepub async fn kill(&mut self) -> Result<()>
pub async fn kill(&mut self) -> Result<()>
Ends the child, as start_kill does, and waits
for its exit.
use nuclei::process::Command;
let mut child = Command::new("sleep").arg("60").spawn()?;
child.kill().await?;
assert!(child.try_wait()?.is_some());§Errors
As for start_kill and wait.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Child
impl !RefUnwindSafe for Child
impl !UnwindSafe for Child
impl Send for Child
impl Sync for Child
impl Unpin for Child
impl UnsafeUnpin for Child
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more