Function reboot [src]
Prototype
pub fn reboot(cmd: RebootCommand) RebootError!void
Parameters
cmd: RebootCommand
Possible Errors
The Operating System returned an undocumented error code.
This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.
When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.
Source
pub fn reboot(cmd: RebootCommand) RebootError!void {
switch (native_os) {
.linux => {
switch (linux.E.init(linux.reboot(
.MAGIC1,
.MAGIC2,
cmd,
switch (cmd) {
.RESTART2 => |s| s,
else => null,
},
))) {
.SUCCESS => {},
.PERM => return error.PermissionDenied,
else => |err| return std.posix.unexpectedErrno(err),
}
switch (cmd) {
.CAD_OFF => {},
.CAD_ON => {},
.SW_SUSPEND => {},
.HALT => unreachable,
.KEXEC => unreachable,
.POWER_OFF => unreachable,
.RESTART => unreachable,
.RESTART2 => unreachable,
}
},
else => @compileError("Unsupported OS"),
}
}