1 /* reboot.c - Restart, halt or powerdown the system.
3 * Copyright 2013 Elie De Brauwer <eliedebrauwer@gmail.com>
5 USE_REBOOT(NEWTOY(reboot, "fn", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
6 USE_REBOOT(OLDTOY(halt, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
7 USE_REBOOT(OLDTOY(poweroff, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
13 usage: reboot/halt/poweroff [-fn]
15 Restart, halt or powerdown the system.
18 -n Don't sync before stopping the system.
23 #include <sys/reboot.h>
25 void reboot_main(void)
27 int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF},
28 sigs[] = {SIGINT, SIGUSR1, SIGUSR2}, idx;
30 if (!(toys.optflags & FLAG_n)) sync();
32 idx = stridx("hp", *toys.which->name)+1;
33 if (toys.optflags & FLAG_f) toys.exitval = reboot(types[idx]);
34 else toys.exitval = kill(1, sigs[idx]);