Process v0.1.0
Exit
pub func Exit(code: int32)
Ends the calling process with code.
Only the low eight bits reach a waiting parent. Does not return, and nothing is flushed or destroyed on the way
out.
Parameters
| Name | Type | Description |
|---|---|---|
code | int32 | the status to report to the parent |
GetPid
pub func GetPid() -> ProcessId
The calling process's own identifier. Cannot fail. Runs in constant time and allocates nothing.
Returns: the calling process's identifier
CtlKernel
pub const CtlKernel: int32 = 1;
CTL_KERN: the sysctl branch describing the kernel and its processes.
KernelProcess
pub const KernelProcess: int32 = 14;
KERN_PROC: the leaf under CtlKernel describing processes.
KernelProcessPathname
pub const KernelProcessPathname: int32 = 12;
KERN_PROC_PATHNAME: the leaf under KernelProcess holding a process's executable path.
QueryExecutablePath
pub func QueryExecutablePath(
buffer: *var char8,
length: *var uint
) -> int64
Writes the absolute path of the calling process's executable into buffer, NUL-terminated.
This is the kern.proc.pathname sysctl for process -1, the caller. length holds the buffer's size on entry
and, on success, the path's length including its terminator.
Parameters
| Name | Type | Description |
|---|---|---|
buffer | *var char8 | receives the path |
length | *var uint | the buffer's size in bytes, then the bytes written |
Returns: zero, or a negative error number, ENOMEM when the buffer is too short