Module process/command
High-level child-process spawning with builder-style configuration.
Wraps std/sys/process with a fluent API for constructing argv, capturing
stdout/stderr through pipes, and waiting for the child to exit.
Example
{ Command } :: import "std/process/command";
{ Exception, AnyError } :: import "std/error";
main :: (fn(io : Io, exn : Exception) -> unit)({
cmd := Command.new(`echo`);
cmd.arg(`hello`);
cmd.arg(`world`);
out := io.await(cmd.output(io), { io, exn });
assert(out.status.success(), "echo should succeed");
});
Types
Builder for a child-process invocation.
Construct with Command.new(program), then chain mutating builder methods
(arg, args, env_clear) before invoking status() or output().
Fields
| Name | Type | Description |
|---|---|---|
_program | String | |
_args | ArrayList(String) | |
_stdin_fd | i32 | |
_stdout_fd | i32 | |
_stderr_fd | i32 |
impl(Command, ...)
new : (Command) fn(program : String) -> Commandarg : (Command) fn(self : Command, a : String) -> unitimpl(Command, ...)
status : (Command) fn(self : Command, io : Io) -> Impl(Future(ExitStatus, IoExn))Spawn the child with stdio inherited from the parent, wait for it to
exit, and return its ExitStatus.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Command | |
io | Io |
Returns: Impl(Future(ExitStatus, IoExn))
output : (Command) fn(self : Command, io : Io) -> Impl(Future(Output, IoExn))The result of a finished child process.
Holds the raw waitpid status code along with helpers to extract the exit code and termination signal.
Fields
| Name | Type | Description |
|---|---|---|
raw | i32 | Encoded waitpid status. Use |
impl(ExitStatus, ...)
code : (ExitStatus) fn(self : ExitStatus) -> i32Returns the process exit code (0..255 on Unix). Returns 0 when the process was terminated by a signal.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ExitStatus |
Returns: i32
signal : (ExitStatus) fn(self : ExitStatus) -> i32Returns the signal number that terminated the process, or 0 if the process exited normally.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ExitStatus |
Returns: i32
success : (ExitStatus) fn(self : ExitStatus) -> boolReturns true if the child exited with status code 0.
Parameters
| Name | Type | Notes |
|---|---|---|
self | ExitStatus |
Returns: bool
Captured output of a child process.
Returned by Command.output. Holds the exit status plus the bytes captured
from the child's stdout and stderr.
Fields
| Name | Type | Description |
|---|---|---|
status | ExitStatus | Spawn the child with stdio inherited from the parent, wait for it to
exit, and return its |
stdout | ArrayList(u8) | |
stderr | ArrayList(u8) |