xur_

> module

std::process

spawning and controlling child processes

use std::process; feature process native only

std::process starts child processes and waits for them to finish. A child shares the script's stdin, stdout and stderr, and its current directory and environment.

> functions

# spawn(program: str, args: list<str>) -> Result<Process, str>

Starts program with the arguments args. A program without a path separator is looked up in PATH. The program is run directly, not through a shell. Returns Err with the message if it can't be started.

> types

┌ type Process

A spawned child process.

# process.kill() -> Result<(), str>

Kills the child (SIGKILL on Unix).

# process.pid() -> u32

The child's process ID.

# process.try_wait() -> Result<Option<i32>, str>

Like wait, but returns None at once if the child is still running.

# process.wait() -> Result<i32, str>

Waits for the child to exit and returns its exit code, or -1 if it was killed by a signal.

> examples

use std::process;
use std::io;

fn main() -> Result<(), str> {
    let child = process::spawn("echo", ["hello"])?;
    let code = child.wait()?;
    io::println("exited with {}", code);
    Ok(())
}