process
Run child processes: spawn them, capture their output, stream their stdio, connect them into pipelines, deliver signals, manage process groups, and drive pseudo-terminals. Every command is an argv array of strings — there is no shell-string form anywhere, which structurally rules out command injection. Child stdio reuses the io handle model, and a child's environment is set per-call rather than globally.
process:run
[$process:run] -> element — Spawn an argv command, run it to completion, and return a proc-result with captured stdout, stderr, and exit code.
[?lib 'cx-stdlib/process']
[$process:run ("echo", "hello")]
cx-err:CXER0271
process:spawn
[$process:spawn] -> element — Start an argv command and return a proc handle for streaming its stdio and managing its lifecycle.
[?lib 'cx-stdlib/process']
[$process:spawn ("tail", "-f", "/var/log/app.log")]
cx-err:CXER0271
process:stdin
[$process:stdin] -> element — Return the child's writable stdin handle; closing it signals EOF to the child.
[?lib 'cx-stdlib/process']
[$process:stdin [$process:spawn ("cat")]]
cx-err:CXER0271
process:stdout
[$process:stdout] -> element — Return the child's readable stdout handle for incremental consumption.
[?lib 'cx-stdlib/process']
[$process:stdout [$process:spawn ("echo", "hi")]]
cx-err:CXER0271
process:stderr
[$process:stderr] -> element — Return the child's readable stderr handle for incremental consumption.
[?lib 'cx-stdlib/process']
[$process:stderr [$process:spawn ("echo", "hi")]]
cx-err:CXER0271
process:pid
[$process:pid] -> int — Return the child's operating-system process id.
[?lib 'cx-stdlib/process']
[$process:pid [$process:spawn ("sleep", "30")]]
cx-err:CXER0271
process:wait
[$process:wait] -> int — Block until the child exits, reap it, and return its exit code.
[?lib 'cx-stdlib/process']
[$process:wait [$process:spawn ("echo", "hi")]]
cx-err:CXER0271
process:wait-timeout
[$process:wait-timeout] -> [or int [sequence int]] — Block up to ms for the child to exit, returning its exit code or absence if still running.
[?lib 'cx-stdlib/process']
[$process:wait-timeout [$process:spawn ("sleep", "30")] 100]
cx-err:CXER0271
process:poll
[$process:poll] -> [or int [sequence int]] — Check without blocking, returning the child's exit code or absence if it is still running.
[?lib 'cx-stdlib/process']
[$process:poll [$process:spawn ("sleep", "30")]]
cx-err:CXER0271
process:close
[$process:close] -> null — Release the handle, closing open stdio and reaping the child; idempotent and does not kill a running child.
[?lib 'cx-stdlib/process']
[$process:close [$process:spawn ("echo", "hi")]]
cx-err:CXER0271
process:pipeline
[$process:pipeline] -> element — Connect stages end-to-end and return a pipeline-result with a pipefail-aggregate exit code.
[?lib 'cx-stdlib/process']
[$process:pipeline ([stage [argv "printf" "a\nb\nERR\n"]], [stage [argv "grep" "ERR"]])]
cx-err:CXER0271
process:send-signal
[$process:send-signal] -> null — Deliver the named signal atom to the child; a no-op if it has already exited.
[?lib 'cx-stdlib/process']
[$process:send-signal [$process:spawn ("sleep", "30")] :hup]
cx-err:CXER0271
process:terminate
[$process:terminate] -> null — Deliver SIGTERM to the child for polite, catchable termination.
[?lib 'cx-stdlib/process']
[$process:terminate [$process:spawn ("sleep", "30")]]
cx-err:CXER0271
process:kill
[$process:kill] -> null — Deliver SIGKILL to the child for forced termination.
[?lib 'cx-stdlib/process']
[$process:kill [$process:spawn ("sleep", "30")]]
cx-err:CXER0271
process:kill-group
[$process:kill-group] -> null — Signal the child's whole process group, reaching it and every descendant as a unit.
[?lib 'cx-stdlib/process']
[$process:kill-group [$process:spawn ("./serve.sh") new-process-group=true] :term]
cx-err:CXER0271
process:spawn-pty
[$process:spawn-pty] -> element — Start a command attached to a fresh pseudo-terminal so it sees a real tty.
[?lib 'cx-stdlib/process']
[$process:spawn-pty ("vi", "notes.txt")]
cx-err:CXER0271
process:pty
[$process:pty] -> element — Return the pty master, one bidirectional io handle for the child's combined stdio.
[?lib 'cx-stdlib/process']
[$process:pty [$process:spawn-pty ("vi", "notes.txt")]]
cx-err:CXER0271
process:window-size
[$process:window-size] -> element — Return the pty's current window size as a size element with rows and cols.
[?lib 'cx-stdlib/process']
[$process:window-size [$process:spawn-pty ("vi", "notes.txt")]]
cx-err:CXER0271
process:set-window-size
[$process:set-window-size] -> null — Resize the pty's window and deliver SIGWINCH to the child.
[?lib 'cx-stdlib/process']
[$process:set-window-size [$process:spawn-pty ("vi", "notes.txt")] 40 120]
cx-err:CXER0271