std::processProcess execution.
Run external commands and manage child processes.
process.Child is an owned handle. Dropping a Child reaps the OS
process handle: if the child has already exited, drop performs the final
wait; if it is still running, drop kills it and waits for it to exit.
import std::process;
fn main() {
let shell_output = process.run("echo hello");
println(shell_output);
let args: Vec<string> = Vec::new();
args.push("<%s>|<%s>");
args.push("hello world");
args.push("hew");
let output = process.run_argv("printf", args);
println(output.stdout);
let child = process.start("sleep 10");
println(child.wait());
}
try_runRun a shell command synchronously and capture its exit code and output.
runRun a shell command synchronously and return its stdout as a string.
Blocks until the command completes. The command is executed via the system shell.
try_run_argvRun a command without the shell using a Vec<string> argv surface.
run_argvRun a command without the shell using a Vec<string> argv surface.
Panics on launch or argument errors. Use try_run_argv for Result-based
error handling.
try_run_argsLegacy compatibility wrapper for a space-delimited argument string.
This packed-string surface cannot represent empty arguments, quoted
segments, or arguments containing spaces. Prefer
try_run_argv(command, Vec<string>).
run_argsLegacy compatibility wrapper for run_args(command, args, arg_count).
Prefer run_argv(command, Vec<string>) for safe argument passing.
startStart a child process without blocking.
Returns a Child handle that can be waited on or killed.
Note: This function is called start rather than spawn because
spawn is a reserved keyword in Hew (used for spawning actors).
ProcessResultHandleA handle to a completed command invocation inside the runtime.
ChildA handle to a running child process.
Created by process.start(cmd). Use wait() to block until
the process exits, or kill() to terminate it. Dropping the
handle reaps it automatically; a still-running child is killed
and waited on at scope exit.
CommandOutputCaptured output from a completed command.
ProcessErrorStructured execution errors for process launch and argument validation.
InvalidArguments(string)LaunchFailed(string)ChildMethodsMethods available on a Child process.
Block until the child process exits and return its exit code.
Returns 0 for success, non-zero for failure.
Terminate the child process.
Returns 0 on success, non-zero on error.