1 /* vi: set sw=4 ts=4: */
3 * Stuff shared between init, reboot, halt, and poweroff
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
12 #include <sys/types.h>
15 #include <sys/reboot.h>
16 #include <sys/syslog.h>
18 #include "init_shared.h"
20 const char * const init_sending_format = "Sending SIG%s to all processes.";
22 const char * const bb_shutdown_format = "\r%s\n";
23 int bb_shutdown_system(unsigned long magic)
25 int pri = LOG_KERN|LOG_NOTICE|LOG_FACMASK;
28 /* Don't kill ourself */
29 signal(SIGTERM,SIG_IGN);
30 signal(SIGHUP,SIG_IGN);
33 /* Allow Ctrl-Alt-Del to reboot system. */
35 #define RB_ENABLE_CAD 0x89abcdef
37 reboot(RB_ENABLE_CAD);
39 openlog(bb_applet_name, 0, pri);
41 message = "\nThe system is going down NOW !!";
42 syslog(pri, "%s", message);
43 printf(bb_shutdown_format, message);
47 /* Send signals to every process _except_ pid 1 */
49 syslog(pri, init_sending_format, message);
50 printf(bb_shutdown_format, message);
57 syslog(pri, init_sending_format, message);
58 printf(bb_shutdown_format, message);