std.os
std.os: the process.
Signals: `onStop()` makes SIGINT (Ctrl-C) and SIGTERM (`kill`) set a flag instead of ending the program, and `stopRequested()` reads it. The handler only sets the flag, as a C signal handler may; the program checks it where it waits (`std.http`'s `Server.run` does, and returns as `stop` makes it). There are no handler functions: an Aye function is not safe to run inside a signal handler.
args
pub fn args(alloc: Allocator) AllocError![][]u8
The program's arguments; the first is the program itself. The slice is new memory from `alloc` (free it with `alloc.free`); the arguments are not copied.
getenv
pub fn getenv(name: []u8) ?[]u8
The value of the environment variable `name`, or null if it is not set. The slice points into the environment, not into new memory: do not free it, and do not keep it across a change of the environment.
cpuCount
pub fn cpuCount() u32
The number of CPUs that are online (`sysconf`), at least 1.
onStop
pub fn onStop()
From now on SIGINT and SIGTERM do not end the program: they set the flag that `stopRequested` reads. Call it once, at the start of `main`, before starting threads. A `poll` or `accept` that is waiting when the signal comes returns early (EINTR) on the thread that takes it.
stopRequested
pub fn stopRequested() bool
Has SIGINT or SIGTERM come since `onStop`? False when `onStop` was not called. Safe from any thread.
exit
pub extern fn exit(code: i32) noreturn
End the program with the exit status `code`, after flushing `@print` output. Deferred statements do not run.