This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function
exit
Public Function
std.process.exit
pubfnexit(status: u8) noreturn
Exits all threads of the program with the specified status code.
pubfnexit(status: u8) noreturn {
if (builtin.link_libc) {
std.c.exit(status);
} elseswitch (native_os) {
.windows => windows.ntdll.RtlExitUserProcess(status),
.wasi => std.os.wasi.proc_exit(status),
.linux => {
if (!builtin.single_threaded) std.os.linux.exit_group(status);
posix.system.exit(status);
},
.uefi => {
constuefi = std.os.uefi;
// exit() is only available if exitBootServices() has not been called yet.// This call to exit should not fail, so we catch-ignore errors.if (uefi.system_table.boot_services) |bs| {
bs.exit(uefi.handle, @fromBackingInt(@intCast(status)), null) catch {};
}
// If we can't exit, reboot the system instead.uefi.system_table.runtime_services.resetSystem(.cold, @fromBackingInt(@intCast(status)), null);
},
else => posix.system.exit(status),
}
}
Exits all threads of the program with the specified status code.