api

process.ch

Declarations in process.ch

1 declarationsprocess

Declarations

Public only
process#
Publicnamespace
namespace process
process — cross-platform process management.
ProcessOutput#
Publicstruct
struct ProcessOutput { var stdout_data : vector<u8> var stderr_data : vector<u8> }
make#
functionConstructor
func make() : ProcessOutput
delete#
function
func delete(self : *ProcessOutput) : void
ExitStatus#
Publicstruct
struct ExitStatus { var code : int var signaled : bool var signal : int }
ProcessResult#
Publicstruct
struct ProcessResult { var output : ProcessOutput var status : ExitStatus var success : bool }
stdout_str#
Publicfunction
func stdout_str(self : &ProcessResult) : string_view
/ Get stdout as a string view (assumes UTF-8).
stderr_str#
Publicfunction
func stderr_str(self : &ProcessResult) : string_view
/ Get stderr as a string view (assumes UTF-8).
exit_code#
Publicfunction
func exit_code(self : &ProcessResult) : int
/ Get the exit code.
is_success#
Publicfunction
func is_success(self : &ProcessResult) : bool
/ Check whether the process exited successfully.
delete#
function
func delete(self : *ProcessResult) : void
ProcessConfig#
Publicstruct
struct ProcessConfig { var args : vector<string> var env : vector<string> var working_dir : string var capture_stdout : bool var capture_stderr : bool var merge_stdout_stderr : bool var stdin_data : vector<u8> var timeout_ms : int }
default#
Publicfunction
func default() : ProcessConfig
delete#
function
func delete(self : *ProcessConfig) : void
ChildProcess#
Publicstruct
struct ChildProcess { var _unix : var is_running : bool var captured_stdout : vector<u8> var captured_stderr : vector<u8> }
delete#
function
func delete(self : *ChildProcess) : void
PR_Result#
Publictypealias
type PR_Result = Result<ProcessResult, ProcessError>
CP_Result#
Publictypealias
type CP_Result = Result<ChildProcess, ProcessError>
UT_Result#
Publictypealias
type UT_Result = Result<UnitTy, ProcessError>
pr_ok#
function
func pr_ok(v : &ProcessResult, ret : &PR_Result) : void
pr_err#
function
func pr_err(e : ProcessError, ret : &PR_Result) : void
execute#
Publicfunction
func execute(cfg : ProcessConfig) : PR_Result
spawn#
Publicfunction
func spawn(cfg : ProcessConfig) : CP_Result
wait#
Publicfunction
func wait(child : *ChildProcess) : PR_Result
kill_process#
Publicfunction
func kill_process(child : *ChildProcess, signal : int) : UT_Result
is_running#
Publicfunction
func is_running(child : *ChildProcess) : bool
---------------------------------------------------------------------------
write_stdin#
Publicfunction
func write_stdin(child : *ChildProcess, data : *vector<u8>) : UT_Result
/ Write data to the child process's stdin pipe.
close_stdin#
Publicfunction
func close_stdin(child : *ChildProcess) : UT_Result
/ Close the stdin pipe of a child process (sends EOF to the child).
try_wait#
Publicfunction
func try_wait(child : *ChildProcess) : PR_Result
/ Reap the child process and return its exit status without blocking.
current_pid#
Publicfunction
func current_pid() : int
---------------------------------------------------------------------------
sleep_ms#
Publicfunction
func sleep_ms(ms : int) : void
/ Sleep for the given number of milliseconds.
child_pid#
Publicfunction
func child_pid(child : *ChildProcess) : int
/ Get the PID of a child process.