• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* reboot.c - Restart, halt or powerdown the system.
2  *
3  * Copyright 2013 Elie De Brauwer <eliedebrauwer@gmail.com>
4 
5 USE_REBOOT(NEWTOY(reboot, "", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
6 
7 config REBOOT
8   bool "reboot"
9   default y
10   help
11     usage: reboot
12 
13     Restart the system.
14 
15 */
16 #define FOR_reboot
17 #include "toys.h"
18 #include <sys/reboot.h>
19 
reboot_main(void)20 void reboot_main(void)
21 {
22   int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF},
23       sigs[] = {SIGTERM, SIGUSR1, SIGUSR2}, idx;
24 
25   idx = stridx("hp", *toys.which->name)+1;
26   toys.exitval = reboot(types[idx]);
27 }
28