aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/init.c
diff options
context:
space:
mode:
authorIsaac Dunham <ibid.ag@gmail.com>2015-08-05 21:33:43 -0500
committerRob Landley <rob@landley.net>2015-08-05 21:33:43 -0500
commita12eec740dc6d0c533fb7d83a0a54de6d3abb17c (patch)
tree91faf8dbe95712c786c33ec20e9c96eba1748318 /toys/pending/init.c
parent5f225ca241cd927ebf148d714ab7e1f69461522c (diff)
downloadtoybox-a12eec740dc6d0c533fb7d83a0a54de6d3abb17c.tar.gz
reboot: signal init, add -f option to call reboot();
init: use SIGINT, use xsignal() Now that oneit supports the same signals as our "sysv"-init for shutdown, make reboot et al. signal pid 1 with the appropriate signal. Of these signals, only SIGINT works with sysvinit 2.88, causing a reboot. The others are only supported in Busybox init. Also, make init accept SIGINT and use xsignal().
Diffstat (limited to 'toys/pending/init.c')
-rw-r--r--toys/pending/init.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/toys/pending/init.c b/toys/pending/init.c
index 529c1b9e..8d0d3f02 100644
--- a/toys/pending/init.c
+++ b/toys/pending/init.c
@@ -348,6 +348,7 @@ static void halt_poweroff_reboot_handler(int sig_no)
reboot_magic_no=RB_POWER_OFF;
break;
case SIGTERM:
+ case SIGINT:
error_msg("Requesting system reboot");
reboot_magic_no=RB_AUTOBOOT;
break;
@@ -415,7 +416,7 @@ static void pause_handler(int sig_no)
errno_backup = errno;
signal_backup = caught_signal;
- signal(SIGCONT, catch_signal);
+ xsignal(SIGCONT, catch_signal);
while(1) {
if (caught_signal == SIGCONT) break;
@@ -460,10 +461,11 @@ void init_main(void)
putenv("USER=root");
inittab_parsing();
- signal(SIGUSR1, halt_poweroff_reboot_handler);//halt
- signal(SIGUSR2, halt_poweroff_reboot_handler);//poweroff
- signal(SIGTERM, halt_poweroff_reboot_handler);//reboot
- signal(SIGQUIT, restart_init_handler);//restart init
+ xsignal(SIGUSR1, halt_poweroff_reboot_handler);//halt
+ xsignal(SIGUSR2, halt_poweroff_reboot_handler);//poweroff
+ xsignal(SIGTERM, halt_poweroff_reboot_handler);//reboot
+ xsignal(SIGINT, halt_poweroff_reboot_handler);//reboot
+ xsignal(SIGQUIT, restart_init_handler);//restart init
memset(&sig_act, 0, sizeof(sig_act));
sigfillset(&sig_act.sa_mask);
sigdelset(&sig_act.sa_mask, SIGCONT);