pub struct Child {
pub stdin: Option<ChildStdin>,
pub stdout: Option<ChildStdout>,
pub stderr: Option<ChildStderr>,
/* private fields */
}
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<()>
pub fn kill(&mut self) -> Result<()>
Forces the child process to exit. If the child has already exited, `Ok(())`` is returned.
Sourcepub async fn wait(self) -> Result<ExitStatus>
pub async fn wait(self) -> Result<ExitStatus>
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>
pub async fn wait_with_output(self) -> Result<Output>
Simultaneously waits for the child to exit and collect all remaining output on the stdout/stderr handles, returning an Output instance.