Std\Process
Process – process management, environment, and command execution.
Provides environment variable access, command execution with output
capture, and subprocess management with stdin/stdout pipes. Async
functions (exec, execStatus, readAll, wait) block the
current fiber without blocking the OS thread.
Functions
Section titled “Functions”getenv : String -> String
Section titled “getenv : String -> String”Get the value of an environment variable. Returns an empty string if not set.
import getenv from Std\Process ingetenv "HOME" # => "/home/user"getcwd : String
Section titled “getcwd : String”Returns the current working directory.
import getcwd from Std\Process ingetcwd # => "/home/user/project"exit : Int -> Int
Section titled “exit : Int -> Int”Terminate the process with the given exit code.
import exit from Std\Process inexit 0exec : String -> String
Section titled “exec : String -> String”Execute a shell command and return its stdout as a string. Async.
import exec from Std\Process inlet output = exec "ls -la" inprintln outputexecStatus : String -> Int
Section titled “execStatus : String -> Int”Execute a shell command and return its exit status code. Async.
import execStatus from Std\Process inlet code = execStatus "make build" inprintln (show code)setenv : String -> String -> Int
Section titled “setenv : String -> String -> Int”Set an environment variable. Returns 0 on success.
import setenv from Std\Process insetenv "MY_VAR" "hello"hostname : String
Section titled “hostname : String”Returns the system hostname.
import hostname from Std\Process inhostname # => "myhost"spawn : String -> Int
Section titled “spawn : String -> Int”Spawn a subprocess without waiting for it to finish. Returns a process handle (Int).
import spawn, wait from Std\Process inlet proc = spawn "sleep 5" inlet status = wait proc inprintln (show status)readLine : Int -> String
Section titled “readLine : Int -> String”Read a single line from the subprocess stdout.
import spawn, readLine from Std\Process inlet proc = spawn "echo hello" inreadLine proc # => "hello"readAll : Int -> String
Section titled “readAll : Int -> String”Read all remaining stdout from a subprocess as a string. Async.
wait : Int -> Int
Section titled “wait : Int -> Int”Wait for a subprocess to exit and return its exit status. Async.
kill : Int -> Int -> Int
Section titled “kill : Int -> Int -> Int”Send a signal to a subprocess. Returns 0 on success.
import spawn, kill from Std\Process inlet proc = spawn "sleep 100" inkill proc 15 # SIGTERMwriteStdin : Int -> String -> Int
Section titled “writeStdin : Int -> String -> Int”Write a string to the subprocess stdin. Returns the number of bytes written.
closeStdin : Int -> Int
Section titled “closeStdin : Int -> Int”Close the stdin pipe of a subprocess. Returns 0 on success.
pid : Int -> Int
Section titled “pid : Int -> Int”Returns the OS process ID of a subprocess.
import spawn, pid from Std\Process inlet proc = spawn "sleep 10" inpid proc # => 12345