Struct cargo_util::ProcessBuilder[][src]

pub struct ProcessBuilder { /* fields omitted */ }
Expand description

A builder object for an external process, similar to std::process::Command.


Creates a new ProcessBuilder with the given executable path.

(chainable) Sets the executable for the process.

(chainable) Adds arg to the args list.

(chainable) Adds multiple args to the args list.

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

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

(chainable) Sets an environment variable for the process.

(chainable) Unsets an environment variable for the process.

Gets the executable name.

Gets the program arguments.

Gets the current working directory for the process.

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

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

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

Enables environment variable display.

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

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 at 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.

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

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.

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

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


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"));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.