Skip to content
rodeo

process

local process = require("@rodeo/process")
EntryDescription
ProcessHandleHandle to a process started with create. Fields are populated when
ProcessResultResult returned by run and system.
ProcessRunOptionsOptions accepted by run, system, and create. All fields optional.
StdioKindHow a stdio stream should be wired for a spawned process. "default"
argsThe command-line arguments passed to this rodeo execution after --.
createSpawns args as a child process without waiting. Returns a handle with
cwdReturns the current working directory.
envA read-only view of environment variables visible to this execution.
execpathReturns the path of the running rodeo binary.
exitExits the current execution with the given code.
homedirReturns the user’s home directory.
killTerminates a process started with create.
platformReturns the run client’s OS: "macos", "windows", or "linux".
runRuns args (or an existing handle), blocking until completion. Returns
systemLike run, but takes a single shell-style command string.

Handle to a process started with create. Fields are populated when

the corresponding stdio is "piped"; otherwise nil.

type ProcessHandle = {
__rodeo_pid: string,
stdin: stream.StreamHandle?,
stdout: stream.StreamHandle?,
stderr: stream.StreamHandle?,
}

Result returned by run and system.

out and err are the captured stdout and stderr, empty when run waits on a create handle.

type ProcessResult = {
ok: boolean, -- true when the process exited with status 0
exitcode: number, -- -1 when the process was terminated by a signal
out: string,
err: string,
signal: number?, -- the signal that terminated the process (Unix)
}

Options accepted by run, system, and create. All fields optional.

stdio applies to all three streams; per-stream overrides win.

env adds variables to the inherited environment.

input (run and system only) is written to the child’s stdin, which is then closed; without it, a child that reads stdin gets end-of-file.

shell (system only) is the shell that runs the command; the default is sh, or cmd on Windows.

type ProcessRunOptions = {
cwd: string?,
stdio: StdioKind?,
stdin: StdioKind?,
stdout: StdioKind?,
stderr: StdioKind?,
env: { [string]: string }?,
input: (string | buffer)?,
shell: string?,
}

How a stdio stream should be wired for a spawned process. "default"

uses the parent’s stream, "piped" captures into a StreamHandle,

"inherit" passes through, "none" discards, "tee" mirrors to both

a capture and the parent’s stream.

type StdioKind = "default" | "piped" | "inherit" | "none" | "tee"

The command-line arguments passed to this rodeo execution after --.

any) :: { string }

Spawns args as a child process without waiting. Returns a handle with

stdin/stdout/stderr stream handles for live interaction.

(args: { string }, options: ProcessRunOptions?) -> ProcessHandle

Returns the current working directory.

() -> string

A read-only view of environment variables visible to this execution.

any) :: { [string]: string? }

Returns the path of the running rodeo binary.

() -> string

Exits the current execution with the given code.

(code: number) -> ()

Returns the user’s home directory.

() -> string

Terminates a process started with create.

(handle: ProcessHandle) -> ()

Returns the run client’s OS: "macos", "windows", or "linux".

() -> string

Runs args (or an existing handle), blocking until completion. Returns

captured stdout/stderr and exit code.

(argsOrHandle: { string } | ProcessHandle, options: ProcessRunOptions?) -> ProcessResult

Like run, but takes a single shell-style command string.

(command: string, options: ProcessRunOptions?) -> ProcessResult