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.
This commit is contained in:
parent
8fc32d9326
commit
d112f8fa5e
43
init/init.c
43
init/init.c
@ -175,7 +175,7 @@ static const char * const environment[] = {
|
|||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
static void delete_init_action(struct init_action *a);
|
static void delete_init_action(struct init_action *a);
|
||||||
static int waitfor(const struct init_action *a, pid_t pid);
|
static int waitfor(const struct init_action *a, pid_t pid);
|
||||||
static void halt_signal(int sig);
|
static void shutdown_signal(int sig);
|
||||||
|
|
||||||
|
|
||||||
static void loop_forever(void)
|
static void loop_forever(void)
|
||||||
@ -395,7 +395,7 @@ static void open_new_terminal(const char *device, char fail) {
|
|||||||
if (fail)
|
if (fail)
|
||||||
_exit(1);
|
_exit(1);
|
||||||
/* else */
|
/* else */
|
||||||
halt_signal(SIGUSR1);
|
shutdown_signal(SIGUSR1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,33 +746,30 @@ static void exec_signal(int sig ATTRIBUTE_UNUSED)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void halt_signal(int sig ATTRIBUTE_UNUSED)
|
static void shutdown_signal(int sig)
|
||||||
{
|
{
|
||||||
|
char *m;
|
||||||
|
int rb;
|
||||||
|
|
||||||
shutdown_system();
|
shutdown_system();
|
||||||
message(CONSOLE | LOG, "The system is halted.");
|
|
||||||
sync();
|
|
||||||
|
|
||||||
/* allow time for last message to reach serial console */
|
if (sig == SIGTERM) {
|
||||||
sleep(2);
|
m = "reboot";
|
||||||
|
rb = RB_AUTOBOOT;
|
||||||
if (sig == SIGUSR2)
|
} else if (sig == SIGUSR2) {
|
||||||
init_reboot(RB_POWER_OFF);
|
m = "poweroff";
|
||||||
else
|
rb = RB_POWER_OFF;
|
||||||
init_reboot(RB_HALT_SYSTEM);
|
} else {
|
||||||
|
m = "halt";
|
||||||
loop_forever();
|
rb = RB_HALT_SYSTEM;
|
||||||
}
|
}
|
||||||
|
message(CONSOLE | LOG, "Requesting system %s.", m);
|
||||||
static void reboot_signal(int sig ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
shutdown_system();
|
|
||||||
message(CONSOLE | LOG, "Please stand by while rebooting the system.");
|
|
||||||
sync();
|
sync();
|
||||||
|
|
||||||
/* allow time for last message to reach serial console */
|
/* allow time for last message to reach serial console */
|
||||||
sleep(2);
|
sleep(2);
|
||||||
|
|
||||||
init_reboot(RB_AUTOBOOT);
|
init_reboot(rb);
|
||||||
|
|
||||||
loop_forever();
|
loop_forever();
|
||||||
}
|
}
|
||||||
@ -1020,10 +1017,10 @@ int init_main(int argc, char **argv)
|
|||||||
* clear all of these in run() */
|
* clear all of these in run() */
|
||||||
signal(SIGHUP, exec_signal);
|
signal(SIGHUP, exec_signal);
|
||||||
signal(SIGQUIT, exec_signal);
|
signal(SIGQUIT, exec_signal);
|
||||||
signal(SIGUSR1, halt_signal);
|
signal(SIGUSR1, shutdown_signal);
|
||||||
signal(SIGUSR2, halt_signal);
|
signal(SIGUSR2, shutdown_signal);
|
||||||
signal(SIGINT, ctrlaltdel_signal);
|
signal(SIGINT, ctrlaltdel_signal);
|
||||||
signal(SIGTERM, reboot_signal);
|
signal(SIGTERM, shutdown_signal);
|
||||||
signal(SIGCONT, cont_handler);
|
signal(SIGCONT, cont_handler);
|
||||||
signal(SIGSTOP, stop_handler);
|
signal(SIGSTOP, stop_handler);
|
||||||
signal(SIGTSTP, stop_handler);
|
signal(SIGTSTP, stop_handler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user