Function exit [src]

Exits all threads of the program with the specified status code.

Prototype

pub fn exit(status: u8) noreturn

Parameters

status: u8

Source

pub fn exit(status: u8) noreturn { if (builtin.link_libc) { std.c.exit(status); } if (native_os == .windows) { windows.kernel32.ExitProcess(status); } if (native_os == .wasi) { wasi.proc_exit(status); } if (native_os == .linux and !builtin.single_threaded) { linux.exit_group(status); } if (native_os == .uefi) { const uefi = std.os.uefi; // exit() is only available if exitBootServices() has not been called yet. // This call to exit should not fail, so we don't care about its return value. if (uefi.system_table.boot_services) |bs| { _ = bs.exit(uefi.handle, @enumFromInt(status), 0, null); } // If we can't exit, reboot the system instead. uefi.system_table.runtime_services.resetSystem(.reset_cold, @enumFromInt(status), 0, null); } system.exit(status); }