diff options
Diffstat (limited to 'init/init_shared.c')
| -rw-r--r-- | init/init_shared.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/init/init_shared.c b/init/init_shared.c deleted file mode 100644 index 47480fc21..000000000 --- a/init/init_shared.c +++ /dev/null | |||
| @@ -1,63 +0,0 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | ||
| 2 | /* | ||
| 3 | * Stuff shared between init, reboot, halt, and poweroff | ||
| 4 | * | ||
| 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | ||
| 6 | * | ||
| 7 | * Licensed under GPL version 2, see file LICENSE in this tarball for details. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include "busybox.h" | ||
| 11 | #include <sys/reboot.h> | ||
| 12 | #include <sys/syslog.h> | ||
| 13 | #include "init_shared.h" | ||
| 14 | |||
| 15 | const char * const init_sending_format = "Sending SIG%s to all processes."; | ||
| 16 | #ifndef CONFIG_INIT | ||
| 17 | const char * const bb_shutdown_format = "\r%s\n"; | ||
| 18 | int bb_shutdown_system(unsigned long magic) | ||
| 19 | { | ||
| 20 | int pri = LOG_KERN|LOG_NOTICE|LOG_FACMASK; | ||
| 21 | const char *message; | ||
| 22 | |||
| 23 | /* Don't kill ourself */ | ||
| 24 | signal(SIGTERM,SIG_IGN); | ||
| 25 | signal(SIGHUP,SIG_IGN); | ||
| 26 | bb_setpgrp; | ||
| 27 | |||
| 28 | /* Allow Ctrl-Alt-Del to reboot system. */ | ||
| 29 | #ifndef RB_ENABLE_CAD | ||
| 30 | #define RB_ENABLE_CAD 0x89abcdef | ||
| 31 | #endif | ||
| 32 | reboot(RB_ENABLE_CAD); | ||
| 33 | |||
| 34 | openlog(applet_name, 0, pri); | ||
| 35 | |||
| 36 | message = "\nThe system is going down NOW !!"; | ||
| 37 | syslog(pri, "%s", message); | ||
| 38 | printf(bb_shutdown_format, message); | ||
| 39 | |||
| 40 | sync(); | ||
| 41 | |||
| 42 | /* Send signals to every process _except_ pid 1 */ | ||
| 43 | message = "TERM"; | ||
| 44 | syslog(pri, init_sending_format, message); | ||
| 45 | printf(bb_shutdown_format, message); | ||
| 46 | |||
| 47 | kill(-1, SIGTERM); | ||
| 48 | sleep(1); | ||
| 49 | sync(); | ||
| 50 | |||
| 51 | message = "KILL"; | ||
| 52 | syslog(pri, init_sending_format, message); | ||
| 53 | printf(bb_shutdown_format, message); | ||
| 54 | |||
| 55 | kill(-1, SIGKILL); | ||
| 56 | sleep(1); | ||
| 57 | |||
| 58 | sync(); | ||
| 59 | |||
| 60 | reboot(magic); | ||
| 61 | return 0; /* Shrug */ | ||
| 62 | } | ||
| 63 | #endif | ||
