#define RB_HALT 1 #define RB_POWEROFF 2 #define RB_RESTART 3 #define RB_ERROR_RET 0b1 int reboot(int cmd, int flags);
This syscall does the passed action to the system’s power management, the
action is specified with cmd, it can be one of:
RB_HALTSystem activity is terminated and the system will make all needed preparations, but power will not be cut off, instead, the user will have to do so, say, with the power button. Data syncing is up to the user.
RB_POWEROFFThe same as RB_HALT but actually cuts power.
RB_RESTARTThe same as RB_HALT but at the end, the system will reboot.
If the operation fails internally, for any reason, the kernel will panic, for
returning an error instead, one can use RB_ERROR_RET in flags.
This syscall does not return on success, it will only return in the case of
invalid value for cmd, before committing to an operation, or by using
RB_ERROR_RET as previously said. In error, -1 will be returned,
and errno will be set to:
EINVALThe passed cmd is not valid.
EACCESMAC did not allow this.
EIOThe operation failed internally.