aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-11-30 19:10:58 +0000
committerEric Andersen <andersen@codepoet.org>2001-11-30 19:10:58 +0000
commited8a9be2871bce5bfef43bd2edc645a95098df75 (patch)
tree8df3a4a9ced7a9ca47964ecacafce11eaa99d223
parentc3657428d3207d35cda634adbe23f75457f7912b (diff)
downloadbusybox-w32-ed8a9be2871bce5bfef43bd2edc645a95098df75.tar.gz
busybox-w32-ed8a9be2871bce5bfef43bd2edc645a95098df75.tar.bz2
busybox-w32-ed8a9be2871bce5bfef43bd2edc645a95098df75.zip
Patch from Dan Langlois <dan@somanetworks.com> Support SIGSTOP/SIGCONT
for wierd situations when people want init to actualy stop doing anything for a while...
-rw-r--r--init/init.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/init/init.c b/init/init.c
index 8e2368306..d0beb2a9a 100644
--- a/init/init.c
+++ b/init/init.c
@@ -181,6 +181,7 @@ static char *log = VC_5;
181static int kernelVersion = 0; 181static int kernelVersion = 0;
182static char termType[32] = "TERM=linux"; 182static char termType[32] = "TERM=linux";
183static char console[32] = _PATH_CONSOLE; 183static char console[32] = _PATH_CONSOLE;
184sig_atomic_t got_cont = 0;
184 185
185static void delete_initAction(initAction * action); 186static void delete_initAction(initAction * action);
186 187
@@ -473,6 +474,9 @@ static pid_t run(char *command, char *terminal, int get_enter)
473 signal(SIGINT, SIG_DFL); 474 signal(SIGINT, SIG_DFL);
474 signal(SIGTERM, SIG_DFL); 475 signal(SIGTERM, SIG_DFL);
475 signal(SIGHUP, SIG_DFL); 476 signal(SIGHUP, SIG_DFL);
477 signal(SIGCONT, SIG_DFL);
478 signal(SIGSTOP, SIG_DFL);
479 signal(SIGTSTP, SIG_DFL);
476 480
477 if ((fd = device_open(terminal, O_RDWR)) < 0) { 481 if ((fd = device_open(terminal, O_RDWR)) < 0) {
478 if (stat(terminal, &sb) != 0) { 482 if (stat(terminal, &sb) != 0) {
@@ -652,6 +656,9 @@ static void shutdown_system(void)
652 sigaddset(&block_signals, SIGUSR2); 656 sigaddset(&block_signals, SIGUSR2);
653 sigaddset(&block_signals, SIGINT); 657 sigaddset(&block_signals, SIGINT);
654 sigaddset(&block_signals, SIGTERM); 658 sigaddset(&block_signals, SIGTERM);
659 sigaddset(&block_signals, SIGCONT);
660 sigaddset(&block_signals, SIGSTOP);
661 sigaddset(&block_signals, SIGTSTP);
655 sigprocmask(SIG_BLOCK, &block_signals, NULL); 662 sigprocmask(SIG_BLOCK, &block_signals, NULL);
656 663
657 /* Allow Ctrl-Alt-Del to reboot system. */ 664 /* Allow Ctrl-Alt-Del to reboot system. */
@@ -726,6 +733,27 @@ static void ctrlaltdel_signal(int sig)
726 run_actions(CTRLALTDEL); 733 run_actions(CTRLALTDEL);
727} 734}
728 735
736/*
737 * The SIGSTOP & SIGTSTP handler
738 */
739static void stop_handler(int sig)
740{
741 int saved_errno = errno;
742
743 got_cont = 0;
744 while(!got_cont) pause();
745 got_cont = 0;
746 errno = saved_errno;
747}
748
749/*
750 * The SIGCONT handler
751 */
752static void cont_handler(int sig)
753{
754 got_cont = 1;
755}
756
729#endif /* ! DEBUG_INIT */ 757#endif /* ! DEBUG_INIT */
730 758
731static void new_initAction(initActionEnum action, char *process, char *cons) 759static void new_initAction(initActionEnum action, char *process, char *cons)
@@ -925,6 +953,9 @@ extern int init_main(int argc, char **argv)
925 signal(SIGUSR2, halt_signal); 953 signal(SIGUSR2, halt_signal);
926 signal(SIGINT, ctrlaltdel_signal); 954 signal(SIGINT, ctrlaltdel_signal);
927 signal(SIGTERM, reboot_signal); 955 signal(SIGTERM, reboot_signal);
956 signal(SIGCONT, cont_handler);
957 signal(SIGSTOP, stop_handler);
958 signal(SIGTSTP, stop_handler);
928 959
929 /* Turn off rebooting via CTL-ALT-DEL -- we get a 960 /* Turn off rebooting via CTL-ALT-DEL -- we get a
930 * SIGINT on CAD so we can shut things down gracefully... */ 961 * SIGINT on CAD so we can shut things down gracefully... */