System
System module: OS and runtime information.
Exposes host OS/arch detection, process metadata, environment variables, and subprocess execution under a unified System namespace.
Usage: System.os() -- :macos | :linux | :windows | :unknown System.arch() -- :x86_64 | :aarch64 | :x86 | ... System.cpu_count() -- number of logical CPUs System.monotonic_time() -- milliseconds since process start System.env("PATH") -- Some(value) | None System.put_env("KEY", "val") System.argv() -- List(String) System.cwd() -- String System.pid() -- Int System.exit(0) -- terminate process System.cmd("ls", ["-la"]) -- Ok(ProcessResult) | Err(msg) System.version() -- "0.1.0"
Types
Functions
Return the host operating system as an atom. Possible values: :macos, :linux, :windows, :unknown.
Return the host CPU architecture as an atom. Possible values: :x86_64, :aarch64, :x86, or a lowercase uname string.
Return the number of logical CPUs available to the runtime.
Return milliseconds elapsed since the process started. Suitable for rough timing; not a wall-clock time.
let t0 = System.monotonic_time() -- ... work ... let elapsed = System.monotonic_time() - t0
Get the value of an environment variable. Returns Some(value) if set, None if not set.
Set an environment variable.
Return command-line arguments as List(String). argv()[0] is the path to the executable.
Return the current working directory as a String.
Return the OS-level PID of the current process as an Int.
Terminate the process with the given exit code.
Run an external command synchronously, capturing stdout. Returns Ok(ProcessResult(exit_code, stdout, stderr)) or Err(msg).
match System.cmd("git", ["status"]) do Ok(r) -> println(System.stdout(r)) Err(msg) -> IO.warn("cmd failed: " ++ msg) end
Extract the exit code from a ProcessResult.
Extract captured stdout from a ProcessResult.
Extract captured stderr from a ProcessResult.
True if the command exited with code 0.
Return the March runtime version string.
System.version() -- "0.1.0"