Process v0.1.0

Source
Ending the process and asking its identifier.

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.

Source

Parameters

NameTypeDescription
codeint32the 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.

Source

Returns: the calling process's identifier

CtlKernel

pub const CtlKernel: int32 = 1;

CTL_KERN: the sysctl branch describing the kernel and its processes.

Source

KernelProcess

pub const KernelProcess: int32 = 14;

KERN_PROC: the leaf under CtlKernel describing processes.

Source

KernelProcessPathname

pub const KernelProcessPathname: int32 = 12;

KERN_PROC_PATHNAME: the leaf under KernelProcess holding a process's executable path.

Source

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.

Source

Parameters

NameTypeDescription
buffer*var char8receives the path
length*var uintthe buffer's size in bytes, then the bytes written

Returns: zero, or a negative error number, ENOMEM when the buffer is too short