Process
Process module: OS process interaction.
run/2 runs a command and waits for it to finish, returning the exit code and captured stdout. run_stream/2 returns a Seq(String) of output lines for pipeline-style processing without buffering the whole output.
env/1 and set_env/2 read and write OS environment variables. cwd/0, argv/0, pid/0 expose the current process context. exit/1 terminates the VM with the given exit code.
Types
Functions
Run command with args, wait for it to finish. Returns Ok(ProcessResult) or Err(msg).
Run command and return its stdout as a Seq(String) of lines. Returns Ok(Seq) or Err(msg).
Get the value of an environment variable. Returns Some(value) or None.
Set an environment variable.
Returns the current working directory.
Terminate the process with the given exit code.
Returns the command-line arguments as List(String) (argv[0] is the executable).
Returns the OS-level PID of the current process.
Spawn a command asynchronously (non-blocking). Returns Ok(LiveProcess) immediately — the child process starts running in the background. Use read_line to consume its stdout, kill to terminate it, and wait_proc to reap its exit code.
Read one line from the live process's stdout. Returns Some(line) for each output line, or None when the process has closed its stdout (typically on exit). Blocks until a full line is available.
Send SIGTERM to the live process.
Wait for the live process to exit and return its exit code. Also closes the stdout channel. Should be called after the process exits (read_line returned None) or after kill.
Extract the exit code from a ProcessResult.
Extract captured stdout from a ProcessResult.
Extract captured stderr from a ProcessResult.
True if the command exited with code 0.