pub struct Child {
pub stdin: Option<ChildStdin>,
pub stdout: Option<ChildStdout>,
pub stderr: Option<ChildStderr>,
/* private fields */
}process only.Expand description
Representation of a running or exited child process.
This structure is used to represent and manage child processes. A child
process is created via the Command struct, which configures the
spawning process and can itself be constructed using a builder-style
interface.
There is no implementation of Drop for child processes,
so if you do not ensure the Child has exited then it will continue to
run, even after the Child handle to the child process has gone out of
scope.
Calling Child::wait (or other functions that wrap around it) will make
the parent process wait until the child has actually exited before
continuing.
See std::process::Child for detailed documents.
Fields§
§stdin: Option<ChildStdin>The handle for writing to the child’s standard input (stdin).
stdout: Option<ChildStdout>The handle for reading from the child’s standard output (stdout).
stderr: Option<ChildStderr>The handle for reading from the child’s standard error (stderr).
Implementations§
Source§impl Child
impl Child
Sourcepub fn kill(&mut self) -> Result<(), Error>
pub fn kill(&mut self) -> Result<(), Error>
Forces the child process to exit. If the child has already exited, `Ok(())`` is returned.
Sourcepub async fn wait(self) -> Result<ExitStatus, Error>
pub async fn wait(self) -> Result<ExitStatus, Error>
Waits for the child to exit completely, returning the status that it
exited with. This function will consume the child. To get the output,
either take stdout and stderr out before calling it, or call
Child::wait_with_output.
Sourcepub async fn wait_with_output(self) -> Result<Output, Error>
pub async fn wait_with_output(self) -> Result<Output, Error>
Simultaneously waits for the child to exit and collect all remaining output on the stdout/stderr handles, returning an Output instance.
Auto Trait Implementations§
impl Freeze for Child
impl RefUnwindSafe for Child
impl Send for Child
impl Sync for Child
impl Unpin for Child
impl UnwindSafe 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more