Skip to content

std.process - ZZ

Run and spawn external processes. Results cross as [status, stdout, stderr] inside Result; spawned children are opaque "process" handles.

import std.process

std.process runs commands (run, run_with_env), spawns non-blocking children (spawn + wait), queries pid, and terminates with exit. Env entries must be K=V — check-time errors name the bad entry.

import std.process
match process.run("ls", ["-la"]) {
.ok(out) => println("status {out[0]}"),
.err(e) => println(e),
}
match process.run_with_env("make", ["test"], ["RUST_BACKTRACE=1"]) {
.ok(out) => println(out[1]),
.err(e) => println(e),
}
// Non-blocking spawn
func main() -> Result<int, str> {
child := process.spawn("ls", ["-la"])?
triple := process.wait(child)? // [status, stdout, stderr]
println(process.pid())
return .ok(0)
}
import std.process
func run_capture(cmd: str, args: [str]) -> Result<str, str> {
return match process.run(cmd, args) {
.ok(out) => {
if out[0] != 0 {
return .err(out[2]) // stderr on failure
}
.ok(out[1]) // stdout
}
.err(e) => .err(e),
}
}

6 entries. Signatures come from the compiler’s own FuncSig table, so they match the runtime exactly; descriptions come from the module guide.

Function Signature Description
std.process.exit exit(code: int) -> unit Terminate current process
std.process.pid pid() -> int Current process ID
std.process.run run(cmd: str, argv: [str]) -> Result<[int | str | str], str> Run, wait, [status,stdout,stderr]
std.process.run_with_env run_with_env(cmd: str, argv: [str], env: [str]) -> Result<[int | str | str], str> Run with env entries K=V
std.process.spawn spawn(cmd: str, argv: [str]) -> Result<process, str> Spawn non-blocking child handle
std.process.wait wait(child: process) -> Result<[int | str | str], str> Wait for child, get triple
  • std.env — Environment variables and the surrounding host environment.
  • std.args — argv access and the flag parser: booleans, integers, strings and subcommands.
  • std.log — Log levels, sinks and spans for structured logging.
  • std.sys — Infallible machine information: OS, CPU, memory and uptime.
  • std.path — Pure lexical path manipulation: join, split, extension and normalisation.
  • std.cell — Shared mutable slots for lock-free hand-off between green threads.

Full index: API reference · Standard library