Struct tokio_process::Child [] [src]

#[must_use = "futures do nothing unless polled"]
pub struct Child { /* fields omitted */ }

Representation of a child process spawned onto an event loop.

This type is also a future which will yield the ExitStatus of the underlying child process. A Child here also provides access to information like the OS-assigned identifier and the stdio streams.

Note: The behavior of drop on a child in this crate is different than the behavior of the standard library. If a tokio_process::Child is dropped before the process finishes then the process will be terminated. In the standard library, however, the process continues executing. This is done because futures in general take drop as a sign of cancellation, and this Child is itself a future. If you'd like to run a process in the background, though, you may use the forget method.

Methods

impl Child
[src]

[src]

Returns the OS-assigned process identifier associated with this child.

[src]

Forces the child to exit.

This is equivalent to sending a SIGKILL on unix platforms.

[src]

Returns a handle for writing to the child's stdin, if it has been captured

[src]

Returns a handle for writing to the child's stdout, if it has been captured

[src]

Returns a handle for writing to the child's stderr, if it has been captured

[src]

Returns a future that will resolve to an Output, containing the exit status, stdout, and stderr of the child process.

The returned future will simultaneously waits for the child to exit and collect all remaining output on the stdout/stderr handles, returning an Output instance.

The stdin handle to the child process, if any, will be closed before waiting. This helps avoid deadlock: it ensures that the child does not block waiting for input from the parent, while the parent waits for the child to exit.

By default, stdin, stdout and stderr are inherited from the parent. In order to capture the output into this Output it is necessary to create new pipes between parent and child. Use stdout(Stdio::piped()) or stderr(Stdio::piped()), respectively, when creating a Command.

[src]

Drop this Child without killing the underlying process.

Normally a Child is killed if it's still alive when dropped, but this method will ensure that the child may continue running once the Child instance is dropped.

Note: this method may leak OS resources depending on your platform. To ensure resources are eventually cleaned up, consider sending the Child instance into an event loop as an alternative to this method.

let child = Command::new("echo").arg("hello").arg("world")
                    .spawn_async()
                    .expect("failed to spawn");

let do_cleanup = child.map(|_| ()) // Ignore result
                      .map_err(|_| ()); // Ignore errors

tokio::spawn(do_cleanup);

Trait Implementations

impl Debug for Child
[src]

[src]

Formats the value using the given formatter. Read more

impl Future for Child
[src]

The type of value that this future will resolved with if it is successful. Read more

The type of error that this future will resolve with if it fails in a normal fashion. Read more

[src]

Query this future to see if its value has become available, registering interest if it is not. Read more

[src]

Block the current thread until this future is resolved. Read more

[src]

Map this future's result to a different type, returning a new future of the resulting type. Read more

[src]

Map this future's error to a different error, returning a new future. Read more

[src]

Map this future's error to any error implementing From for this future's Error, returning a new future. Read more

[src]

Chain on a computation for when a future finished, passing the result of the future to the provided closure f. Read more

[src]

Execute another future after this one has resolved successfully. Read more

[src]

Execute another future if this one resolves with an error. Read more

[src]

Waits for either one of two futures to complete. Read more

[src]

Waits for either one of two differently-typed futures to complete. Read more

[src]

Joins the result of two futures, waiting for them both to complete. Read more

[src]

Same as join, but with more futures.

[src]

Same as join, but with more futures.

[src]

Same as join, but with more futures.

[src]

Convert this future into a single element stream. Read more

[src]

Flatten the execution of this future when the successful result of this future is itself another future. Read more

[src]

Flatten the execution of this future when the successful result of this future is a stream. Read more

[src]

Fuse a future such that poll will never again be called once it has completed. Read more

[src]

Do something with the item of a future, passing it on. Read more

[src]

Catches unwinding panics while polling the future. Read more

[src]

Create a cloneable handle to this future where all handles will resolve to the same result. Read more

impl Drop for Child
[src]

[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl Send for Child

impl !Sync for Child