1 /* vi: set sw=4 ts=4: */
3 * Mini reboot implementation for busybox
5 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
6 * Copyright (C) 1999-2002 by Erik Andersen <andersee@debian.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "init_shared.h"
33 #if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__)
34 #include <sys/reboot.h>
35 #define init_reboot(magic) reboot(magic)
37 #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic)
41 static const int RB_ENABLE_CAD = 0x89abcdef;
42 static const int RB_AUTOBOOT = 0x01234567;
45 extern int reboot_main(int argc, char **argv)
47 char *delay; /* delay in seconds before rebooting */
49 if(bb_getopt_ulflags(argc, argv, "d:", &delay)) {
53 #ifdef CONFIG_USER_INIT
54 /* Don't kill ourself */
55 signal(SIGTERM,SIG_IGN);
56 signal(SIGHUP,SIG_IGN);
59 /* Allow Ctrl-Alt-Del to reboot system. */
60 init_reboot(RB_ENABLE_CAD);
62 message(CONSOLE|LOG, "\n\rThe system is going down NOW !!\n");
65 /* Send signals to every process _except_ pid 1 */
66 message(CONSOLE|LOG, "\rSending SIGTERM to all processes.\n");
71 message(CONSOLE|LOG, "\rSending SIGKILL to all processes.\n");
77 init_reboot(RB_AUTOBOOT);
80 return kill_init(SIGTERM);