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.
This is a raw lookup: Windows CI and many desktop sessions have USERPROFILE
but not HOME.
import getenv from Std\Process ingetenv "PATH" # non-empty when the process inherited a PATHgetcwd : 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 -> [a] -> String
Section titled “exec : String -> [a] -> String”Execute a program directly and return its stdout as a string. The argument
sequence excludes argv[0]. Async; no shell is invoked implicitly.
import exec from Std\Process inlet output = exec "ls" ["-la"] inprintln outputexecStatus : String -> [a] -> Int
Section titled “execStatus : String -> [a] -> Int”Execute a program directly 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 -> [a] -> Linear b
Section titled “spawn : String -> [a] -> Linear b”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 # => 12345getArgs : [a]
Section titled “getArgs : [a]”POSIX argv as a sequence of strings: program or script path, then user
arguments. After yonac -o hello && ./hello a b, the first element is
./hello. After yona script.yona a b, the first element is the script
path.
executablePath : String
Section titled “executablePath : String”Absolute path of the running executable (/proc/self/exe on Linux).
yonaVersion : String
Section titled “yonaVersion : String”The same version string as yonac --version.
tempDir : String
Section titled “tempDir : String”Directory for temporary files (TMPDIR / TEMP / platform default).
tempFile : String -> String -> String
Section titled “tempFile : String -> String -> String”Create a unique empty file from a prefix and suffix (mkstemp style).
The prefix must not contain path separators.
run : String -> [a] -> Int
Section titled “run : String -> [a] -> Int”Execute file with an argument sequence that excludes argv[0] (no shell).
Inherit stdin, stdout, and stderr. Wait and return the exit status.
runWithArgv0 : String -> String -> [a] -> Int
Section titled “runWithArgv0 : String -> String -> [a] -> Int”Execute file while setting the child-visible argv[0] explicitly. The final
argument sequence still excludes argv[0]. This is intended for launchers such
as yona, which execute a temporary binary but expose the script path, -, or
-e as the program name.
execArgs : String -> [a] -> Int
Section titled “execArgs : String -> [a] -> Int”Replace the current process with file and the given arguments, excluding
argv[0] (Unix execve; Windows waits then exits).