patch: init's halt message
Paul Fox
pgf at brightstareng.com
Tue May 30 19:51:03 UTC 2006
bernhard wrote:
> On Tue, May 30, 2006 at 12:37:04PM -0400, Paul Fox wrote:
> >anyone object to changing init's final message? the current
> >message says "The system is halted" when that is not actually
> >the case. when the kernel actually does halt, or powerdown, it
> >will print its own message. seems better if init only announces
> >what it's trying to do, rather than claiming to have done it.
>
> I don't really care myself, but your change looks like it would add to
> the size a bit, yes? I think that the big init does print about the same
> message, so i wouldn't care too much if it adds size, FWIW
>
> Perhaps shrink init elsewhere to accommodate the UI improvement? :)
well, i wasn't planning on changing the long "please stand by"
message one gets when rebooting, but if i do that, and combine
all three shutdown paths, there's a net savings of 42 bytes (by my
count). the patch is a little messy to read, but basically it
combines reboot_signal() and halt_signal() into a new routine
which maps the userlevel signal to the right console message and
the right reboot() parameter.
from a UI point of view, the message will now simply be one of:
"Requesting system reboot."
"Requesting system poweroff."
"Requesting system halt."
(bernhard -- your other message consolidation may still be valid. i
haven't tried it.)
paul
=---------------------
paul fox, pgf at brightstareng.com
Index: init/init.c
===================================================================
RCS file: /cvs/thirdparty/busybox-1.1.3/init/init.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 init.c
--- init/init.c 30 May 2006 15:18:09 -0000 1.1.1.1
+++ init/init.c 30 May 2006 19:21:46 -0000
@@ -176,7 +176,7 @@
/* Function prototypes */
static void delete_init_action(struct init_action *a);
static int waitfor(const struct init_action *a);
-static void halt_signal(int sig);
+static void shutdown_signal(int sig);
static void loop_forever(void)
@@ -732,7 +732,7 @@
} else {
message(LOG | CONSOLE, "Bummer, can't open %s", a->terminal);
}
- halt_signal(SIGUSR1);
+ shutdown_signal(SIGUSR1);
}
/* Make sure the terminal will act fairly normal for us */
@@ -754,33 +754,30 @@
}
}
-static void halt_signal(int sig ATTRIBUTE_UNUSED)
+static void shutdown_signal(int sig)
{
- shutdown_system();
- message(CONSOLE | LOG, "The system is halted.");
- sync();
+ char *m;
+ int rb;
- /* allow time for last message to reach serial console */
- sleep(2);
-
- if (sig == SIGUSR2)
- init_reboot(RB_POWER_OFF);
- else
- init_reboot(RB_HALT_SYSTEM);
-
- loop_forever();
-}
-
-static void reboot_signal(int sig ATTRIBUTE_UNUSED)
-{
shutdown_system();
- message(CONSOLE | LOG, "Please stand by while rebooting the system.");
+
+ if (sig == SIGTERM) {
+ m = "reboot";
+ rb = RB_AUTOBOOT;
+ } else if (sig == SIGUSR2) {
+ m = "poweroff";
+ rb = RB_POWER_OFF;
+ } else {
+ m = "halt";
+ rb = RB_HALT_SYSTEM;
+ }
+ message(CONSOLE | LOG, "Requesting system %s.", m);
sync();
/* allow time for last message to reach serial console */
sleep(2);
- init_reboot(RB_AUTOBOOT);
+ init_reboot(rb);
loop_forever();
}
@@ -1029,10 +1026,10 @@
* clear all of these in run() */
signal(SIGHUP, exec_signal);
signal(SIGQUIT, exec_signal);
- signal(SIGUSR1, halt_signal);
- signal(SIGUSR2, halt_signal);
+ signal(SIGUSR1, shutdown_signal);
+ signal(SIGUSR2, shutdown_signal);
signal(SIGINT, ctrlaltdel_signal);
- signal(SIGTERM, reboot_signal);
+ signal(SIGTERM, shutdown_signal);
signal(SIGCONT, cont_handler);
signal(SIGSTOP, stop_handler);
signal(SIGTSTP, stop_handler);
More information about the busybox
mailing list