std::process - Rust
Description: API documentation for the Rust `process` mod in crate `std`.
Keywords: rust, rustlang, rust-lang, process

# Module std::process 1.0.0 [−] [src]

A module for working with processes.

# Examples

Basic usage where we try to execute the `cat` shell command:

    use std::process::Command;

    let mut child = Command::new("/bin/cat")
                            .arg("file.txt")
                            .spawn()
                            .expect("failed to execute child");

    let ecode = child.wait()
                     .expect("failed to wait on child");

    assert!(ecode.success());Run

Calling a command with input and reading its output:

    use std::process::{Command, Stdio};
    use std::io::Write;

    let mut child = Command::new("/bin/cat")
        .stdin(Stdio::piped())
        .stdout(Stdio::piped())
        .spawn()
        .expect("failed to execute child");

    {
        // limited borrow of stdin
        let stdin = child.stdin.as_mut().expect("failed to get stdin");
        stdin.write_all(b"test").expect("failed to write to stdin");
    }

    let output = child
        .wait_with_output()
        .expect("failed to wait on child");

    assert_eq!(b"test", output.stdout.as_slice());Run

## Structs

Child | Representation of a running or exited child process.
ChildStderr | A handle to a child process's stderr.
ChildStdin | A handle to a child process's stdin.
ChildStdout | A handle to a child process's stdout.
Command | A process builder, providing fine-grained control over how a new process should be spawned.
ExitStatus | Describes the result of a process after it has terminated.
Output | The output of a finished process.
Stdio | Describes what to do with a standard I/O stream for a child process.

## Functions

abort | Terminates the process in an abnormal fashion.
exit | Terminates the current process with the specified exit code.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)