aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2006-06-01 13:17:49 +0000
committerPaul Fox <pgf@brightstareng.com>2006-06-01 13:17:49 +0000
commitd112f8fa5e28fe21cf375d4dc3307dcfbdb3a300 (patch)
tree1f9fd1a6420c2c3c0461f76ef4e5b497a614c388
parent8fc32d9326be21e4f5fb19762ba2bb38081153d5 (diff)
downloadbusybox-w32-d112f8fa5e28fe21cf375d4dc3307dcfbdb3a300.tar.gz
busybox-w32-d112f8fa5e28fe21cf375d4dc3307dcfbdb3a300.tar.bz2
busybox-w32-d112f8fa5e28fe21cf375d4dc3307dcfbdb3a300.zip
make halt and poweroff messages more accurate (i.e., claim "we're about to",
rather than "it's done", and combine with reboot handler to save space.
-rw-r--r--init/init.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/init/init.c b/init/init.c
index d072a2209..0290f667a 100644
--- a/init/init.c
+++ b/init/init.c
@@ -175,7 +175,7 @@ static const char * const environment[] = {
175/* Function prototypes */ 175/* Function prototypes */
176static void delete_init_action(struct init_action *a); 176static void delete_init_action(struct init_action *a);
177static int waitfor(const struct init_action *a, pid_t pid); 177static int waitfor(const struct init_action *a, pid_t pid);
178static void halt_signal(int sig); 178static void shutdown_signal(int sig);
179 179
180 180
181static void loop_forever(void) 181static void loop_forever(void)
@@ -395,7 +395,7 @@ static void open_new_terminal(const char *device, char fail) {
395 if (fail) 395 if (fail)
396 _exit(1); 396 _exit(1);
397 /* else */ 397 /* else */
398 halt_signal(SIGUSR1); 398 shutdown_signal(SIGUSR1);
399 } 399 }
400} 400}
401 401
@@ -746,33 +746,30 @@ static void exec_signal(int sig ATTRIBUTE_UNUSED)
746 } 746 }
747} 747}
748 748
749static void halt_signal(int sig ATTRIBUTE_UNUSED) 749static void shutdown_signal(int sig)
750{ 750{
751 shutdown_system(); 751 char *m;
752 message(CONSOLE | LOG, "The system is halted."); 752 int rb;
753 sync();
754 753
755 /* allow time for last message to reach serial console */
756 sleep(2);
757
758 if (sig == SIGUSR2)
759 init_reboot(RB_POWER_OFF);
760 else
761 init_reboot(RB_HALT_SYSTEM);
762
763 loop_forever();
764}
765
766static void reboot_signal(int sig ATTRIBUTE_UNUSED)
767{
768 shutdown_system(); 754 shutdown_system();
769 message(CONSOLE | LOG, "Please stand by while rebooting the system."); 755
756 if (sig == SIGTERM) {
757 m = "reboot";
758 rb = RB_AUTOBOOT;
759 } else if (sig == SIGUSR2) {
760 m = "poweroff";
761 rb = RB_POWER_OFF;
762 } else {
763 m = "halt";
764 rb = RB_HALT_SYSTEM;
765 }
766 message(CONSOLE | LOG, "Requesting system %s.", m);
770 sync(); 767 sync();
771 768
772 /* allow time for last message to reach serial console */ 769 /* allow time for last message to reach serial console */
773 sleep(2); 770 sleep(2);
774 771
775 init_reboot(RB_AUTOBOOT); 772 init_reboot(rb);
776 773
777 loop_forever(); 774 loop_forever();
778} 775}
@@ -1020,10 +1017,10 @@ int init_main(int argc, char **argv)
1020 * clear all of these in run() */ 1017 * clear all of these in run() */
1021 signal(SIGHUP, exec_signal); 1018 signal(SIGHUP, exec_signal);
1022 signal(SIGQUIT, exec_signal); 1019 signal(SIGQUIT, exec_signal);
1023 signal(SIGUSR1, halt_signal); 1020 signal(SIGUSR1, shutdown_signal);
1024 signal(SIGUSR2, halt_signal); 1021 signal(SIGUSR2, shutdown_signal);
1025 signal(SIGINT, ctrlaltdel_signal); 1022 signal(SIGINT, ctrlaltdel_signal);
1026 signal(SIGTERM, reboot_signal); 1023 signal(SIGTERM, shutdown_signal);
1027 signal(SIGCONT, cont_handler); 1024 signal(SIGCONT, cont_handler);
1028 signal(SIGSTOP, stop_handler); 1025 signal(SIGSTOP, stop_handler);
1029 signal(SIGTSTP, stop_handler); 1026 signal(SIGTSTP, stop_handler);