Module process

Process execution.

Run external commands and manage child processes.

Examples

import std::process;

fn main() {
    // Run a command and capture output
    let output = process.run("ls -la");
    println(output);

    // Spawn a long-running process
    let child = process.start("sleep 10");
    let status = child.wait();
    println(status);
}

Contents

Functions

Function run

pub fn run(command: string) -> string

Run a shell command synchronously and return its stdout as a string.

Blocks until the command completes. The command is executed via the system shell.

Examples

let output = process.run("echo hello");
assert_eq(string_trim(output), "hello");

Function run_args

pub fn run_args(command: string, args: string, arg_count: i32) -> string

Run a command with explicit arguments.

args is a space-separated argument string. arg_count is the number of arguments.

Function start

pub fn start(command: string) -> Child

Start 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).

Examples

let child = process.start("sleep 5");
// ... do other work ...
let status = child.wait();

Types

Struct Child

A handle to a running child process.

Created by process.start(cmd). Use wait() to block until the process exits, or kill() to terminate it.

Traits

Trait ChildMethods

Methods available on a Child process.

Methods

fn wait(self: Child) -> i32 fn kill(self: Child) -> i32