diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-07-22 09:41:39 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-07-22 09:41:39 +0000 |
commit | 932734db6ba4f5aa3830833f70aa99e03a453525 (patch) | |
tree | a254319c3697e8f1493373cd1148a6aa1e74a6a6 /init/reboot.c | |
parent | fa8cf20631cf02ae3e6b0db95a494261df1aee27 (diff) | |
download | busybox-w32-932734db6ba4f5aa3830833f70aa99e03a453525.tar.gz busybox-w32-932734db6ba4f5aa3830833f70aa99e03a453525.tar.bz2 busybox-w32-932734db6ba4f5aa3830833f70aa99e03a453525.zip |
Support reboot, halt, and poweroff independent of busybox init.
Simplify and fixup some logic.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@7091 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'init/reboot.c')
-rw-r--r-- | init/reboot.c | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/init/reboot.c b/init/reboot.c index 5ca8b588a..a3c0000f1 100644 --- a/init/reboot.c +++ b/init/reboot.c | |||
@@ -2,7 +2,6 @@ | |||
2 | /* | 2 | /* |
3 | * Mini reboot implementation for busybox | 3 | * Mini reboot implementation for busybox |
4 | * | 4 | * |
5 | * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>. | ||
6 | * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> |
7 | * | 6 | * |
8 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -30,11 +29,6 @@ | |||
30 | #include "init_shared.h" | 29 | #include "init_shared.h" |
31 | 30 | ||
32 | 31 | ||
33 | #ifndef RB_ENABLE_CAD | ||
34 | static const int RB_ENABLE_CAD = 0x89abcdef; | ||
35 | static const int RB_AUTOBOOT = 0x01234567; | ||
36 | #endif | ||
37 | |||
38 | extern int reboot_main(int argc, char **argv) | 32 | extern int reboot_main(int argc, char **argv) |
39 | { | 33 | { |
40 | char *delay; /* delay in seconds before rebooting */ | 34 | char *delay; /* delay in seconds before rebooting */ |
@@ -43,34 +37,13 @@ extern int reboot_main(int argc, char **argv) | |||
43 | sleep(atoi(delay)); | 37 | sleep(atoi(delay)); |
44 | } | 38 | } |
45 | 39 | ||
46 | #ifdef CONFIG_USER_INIT | 40 | #ifndef CONFIG_INIT |
47 | /* Don't kill ourself */ | 41 | #ifndef RB_AUTOBOOT |
48 | signal(SIGTERM,SIG_IGN); | 42 | #define RB_AUTOBOOT 0x01234567 |
49 | signal(SIGHUP,SIG_IGN); | 43 | #endif |
50 | setpgrp(); | 44 | return(bb_shutdown_system(RB_AUTOBOOT)); |
51 | |||
52 | /* Allow Ctrl-Alt-Del to reboot system. */ | ||
53 | reboot(RB_ENABLE_CAD); | ||
54 | |||
55 | message(CONSOLE|LOG, "\n\rThe system is going down NOW !!\n"); | ||
56 | sync(); | ||
57 | |||
58 | /* Send signals to every process _except_ pid 1 */ | ||
59 | message(CONSOLE|LOG, "\rSending SIGTERM to all processes.\n"); | ||
60 | kill(-1, SIGTERM); | ||
61 | sleep(1); | ||
62 | sync(); | ||
63 | |||
64 | message(CONSOLE|LOG, "\rSending SIGKILL to all processes.\n"); | ||
65 | kill(-1, SIGKILL); | ||
66 | sleep(1); | ||
67 | |||
68 | sync(); | ||
69 | |||
70 | reboot(RB_AUTOBOOT); | ||
71 | return 0; /* Shrug */ | ||
72 | #else | 45 | #else |
73 | return kill_init(SIGTERM); | 46 | return kill_init(SIGUSR2); |
74 | #endif | 47 | #endif |
75 | } | 48 | } |
76 | 49 | ||