Module
pooka/process
src/pooka/process.pookaAn external command is a visitor, with its own voice and exit status.
Run executables with an explicit argument list and capture stdout and stderr separately. A nonzero exit is an Output value, not a launch error. Child stdin starts at EOF; timeout results use None when the deadline wins. The current runner targets POSIX hosts.
import pooka/process
let assert Ok(output) = process.run("printf", ["%s", "hello"])
assert output.stdout == "hello"
API reference
class ProcessError(message: String)
A process failure carrying the details needed by its caller. Keep this value in Result until a boundary can explain it.
message: String
String
fn(String) -> pooka/process.ProcessErrorclass Output(status: Int, stdout: String, stderr: String)
A completed command report: exit status, captured stdout and captured stderr. Nonzero status is still a completed command.
status: Int
Intstdout: String
Stringstderr: String
String
fn(Int, String, String) -> pooka/process.Outputsucceeded() -> Bool
fn() -> BoolCheck whether the command's exit status was zero.
import pooka/process
assert process.Output(0, "", "").succeeded()
exit(code: Int) -> Nil
fn(Int) -> NilEnd the running application VM with the given exit status. This call does not return normally.
import pooka/process
process.exit(0)
run(command: String, args: List(String)) -> Result(Output, ProcessError)
fn(String, List(String)) -> Result(pooka/process.Output, pooka/process.ProcessError)Run an executable with literal arguments and collect both output streams. A nonzero status remains an Output.
import pooka/process
let assert Ok(output) = process.run("printf", ["%s", "oak"])
run_in(
command: String,
args: List(String),
directory: String
) -> Result(Output, ProcessError)
fn(String, List(String), String) -> Result(pooka/process.Output, pooka/process.ProcessError)Run a command with an explicit working directory.
import pooka/process
let result = process.run_in("pwd", [], ".")
run_with_timeout(
command: String,
args: List(String),
milliseconds: Int
) -> Result(Option(Output), ProcessError)
fn(String, List(String), Int) -> Result(Option(pooka/process.Output), pooka/process.ProcessError)Return Some(Output) if the command finishes, None if the deadline wins, or ProcessError for launch failure.
import pooka/process
let result = process.run_with_timeout("printf", ["oak"], 1000)
pid() -> Int
fn() -> IntRead the process identifier supplied by the runtime bridge.
import pooka/process
let identifier = process.pid()