Standard library / process · on the one-page reference
process
Stable —
cwd/chdir go through the same Io
primitives as fs; env and argv()
reuse state the program's own startup already collects;
platform/arch are compile-time constants;
pid()/uptime()/hrtime()/
kill()/umask()/getuid()-family are
raw Linux syscalls; memoryUsage() reads
/proc/self/status. No libc linking required for any of it.
A practical subset of
Node's process
object — kill() can send a signal, but nothing yet
can receive one back into user code, and there's still no IPC or worker
threads. platform()/arch() are called as
functions, not read as properties, the same deviation as
path.sep().
process.cwd()
→ string — the real current working directory.
console.log(process.cwd());
process.chdir(directory)
string → void
process.chdir("/tmp");
console.log(process.cwd());
process.exit(code)
int → void — terminates immediately; nothing after the call runs. Truncates to a byte-sized exit code, matching the OS.
console.log("before");
process.exit(42);
console.log("never runs");
process.env(key)
string → string | null — called as a function rather
than indexed as a property (process.env.FOO in Node), since
Lumen has no dynamic-object indexing.
const home = process.env("HOME");
if (home != null) {
console.log(home);
}
process.platform()
→ string — "linux", "darwin",
"win32", ...
console.log(process.platform()); // linux
process.arch()
→ string — "x64", "arm64", ...
console.log(process.arch()); // x64
process.pid() Wasm: limited
→ int
console.log(process.pid() > 0); // true
process.argv()
→ string[] — deviation from
Node: follows C/POSIX argv convention (index 0 is the invoked
binary itself), not Node's node-then-script convention where a user's
first real argument is argv[2].
const argv: string[] = process.argv();
for (const a of argv) {
console.log(a);
}
argsCount() · arg(i)
→ int · int → string — unnamespaced, pre-dates
process.argv(); reads the same underlying argument data.
console.log(argsCount());
console.log(arg(0));
process.uptime()
→ number — fractional seconds since this process
started. A start timestamp is recorded once at program startup (the same
monotonic clock time.monotonic() uses); each call
subtracts.
console.log(process.uptime() >= 0.0);
process.hrtime()
→ i64 — monotonic nanoseconds. Deviation from
Node: a single scalar, not Node's [seconds, nanoseconds]
tuple — Lumen's i64 is a real 64-bit integer (unlike a
JS double), so there's no precision problem to work around by splitting
it, the same reasoning Node's own newer hrtime.bigint()
uses. Diff two readings for an elapsed duration.
const start: i64 = process.hrtime();
const end: i64 = process.hrtime();
console.log(end > start);
process.memoryUsage()
→ { rss: i64, vsize: i64 } (bytes) —
parsed from /proc/self/status. Deviation from
Node: only rss/vsize, not Node's full
heapTotal/heapUsed/external/
arrayBuffers shape — those describe V8's
garbage-collected heap, which has no Lumen-side equivalent.
const mem = process.memoryUsage();
console.log(mem.rss);
console.log(mem.vsize);
process.kill(pid, signal)
(int, string) → bool — sends a signal to another
process. signal is a name ("SIGTERM" or
"TERM", either works); an unrecognized name resolves to
POSIX's signal 0 (existence/permission check only, never
destructive) rather than guessing. Returns whether the syscall
succeeded.
const ok: bool = process.kill(childPid, "SIGTERM");
console.log(ok);
process.umask() · process.setUmask(mask)
→ int · int → int — two names instead of one
arity-overloaded call (Node's process.umask([mask])
dispatches on argument count; Lumen's checker has no call-site
overloading, the same reason cwd()/chdir() are
two names). setUmask returns the previous mask,
matching what the real umask() syscall itself returns.
const old: int = process.umask();
console.log(old);
process.getuid() · getgid() · geteuid() · getegid() Wasm: limited
→ int — POSIX-only, raw syscalls, the same shape as
pid().
console.log(process.getuid());
console.log(process.getgid());
process.abort()
→ void — abnormal termination via SIGABRT.
Nothing after the call runs.
console.log("before");
process.abort();
console.log("never runs");
process.version()
→ string — not Node's version. Lumen's own version marker, matching the repository's latest release tag. Bumped by hand alongside future tags.
console.log(process.version());