ProcessBuilder in cargo_test_support - Rust (original) (raw)

Struct ProcessBuilder

Source

pub struct ProcessBuilder {
    program: OsString,
    args: Vec<OsString>,
    env: BTreeMap<String, Option<OsString>>,
    cwd: Option<OsString>,
    wrappers: Vec<OsString>,
    jobserver: Option<Client>,
    display_env_vars: bool,
    retry_with_argfile: bool,
    stdin: Option<Vec<u8>>,
}

Expand description

Source§

Source

Creates a new ProcessBuilder with the given executable path.

Source

(chainable) Sets the executable for the process.

Source

(chainable) Adds arg to the args list.

Source

(chainable) Adds multiple args to the args list.

Source

(chainable) Replaces the args list with the given args.

Source

(chainable) Sets the current working directory of the process.

Source

(chainable) Sets an environment variable for the process.

Source

(chainable) Unsets an environment variable for the process.

Source

Gets the executable name.

Source

Gets the program arguments.

Source

Gets the current working directory for the process.

Source

Gets an environment variable as the process will see it (will inherit from environment unless explicitly unset).

Source

Gets all environment variables explicitly set or unset for the process (not inherited vars).

Source

Sets the make jobserver. See the jobserver crate for more information.

Source

Enables environment variable display.

Source

Source

Sets a value that will be written to stdin of the process on launch.

Source

Source

Runs the process, waiting for completion, and mapping non-success exit codes to an error.

Source

Replaces the current process with the target process.

On Unix, this executes the process using the Unix syscall execvp, which will block this process, and will only return if there is an error.

On Windows this isn’t technically possible. Instead we emulate it to the best of our ability. One aspect we fix here is that we specify a handler for the Ctrl-C handler. In doing so (and by effectively ignoring it) we should emulate proxying Ctrl-C handling to the application at hand, which will either terminate or handle it itself. According to Microsoft’s documentation athttps://docs.microsoft.com/en-us/windows/console/ctrl-c-and-ctrl-break-signals. the Ctrl-C signal is sent to all processes attached to a terminal, which should include our child process. If the child terminates then we’ll reap them in Cargo pretty quickly, and if the child handles the signal then we won’t terminate (and we shouldn’t!) until the process itself later exits.

Source

Source

Executes the process, returning the stdio output, or an error if non-zero exit status.

Source

Executes a command, passing each line of stdout and stderr to the supplied callbacks, which can mutate the string data.

If any invocations of these function return an error, it will be propagated.

If capture_output is true, then all the output will also be buffered and stored in the returned Output object. If it is false, no caching is done, and the callbacks are solely responsible for handling the output.

Source

Converts ProcessBuilder into a std::process::Command, and handles the jobserver, if present.

Note that this method doesn’t take argfile fallback into account. The caller should handle it by themselves.

Source

Wraps an existing command with the provided wrapper, if it is present and valid.

§Examples
use cargo_util::ProcessBuilder;
// Running this would execute `rustc`
let cmd = ProcessBuilder::new("rustc");

// Running this will execute `sccache rustc`
let cmd = cmd.wrapped(Some("sccache"));

§

§

§

§

§

§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 160 bytes