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
Returns the command-line arguments as List(String) (argv[0] is the executable).
Returns the current working directory.
Get the value of an environment variable. Returns Some(value) or None.
Terminate the process with the given exit code.
Extract the exit code from a ProcessResult.
Send SIGTERM to the live process.
True if the command exited with code 0.
Returns the OS-level PID of the current process.
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.
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).
Set an environment variable.
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.
Extract captured stderr from a ProcessResult.
Extract captured stdout from a ProcessResult.
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.
Write raw bytes to the live process's stdin. The data is flushed immediately so the child process sees it without delay. Include a trailing newline if the child reads line-by-line.