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-ed8a9be2871bce5bfef43bd2edc645a95098df75.tar.gz
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;
static int kernelVersion = 0;
static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE;
+sig_atomic_t got_cont = 0;
static void delete_initAction(initAction * action);
@@ -473,6 +474,9 @@ static pid_t run(char *command, char *terminal, int get_enter)
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
+ signal(SIGCONT, SIG_DFL);
+ signal(SIGSTOP, SIG_DFL);
+ signal(SIGTSTP, SIG_DFL);
if ((fd = device_open(terminal, O_RDWR)) < 0) {
if (stat(terminal, &sb) != 0) {
@@ -652,6 +656,9 @@ static void shutdown_system(void)
sigaddset(&block_signals, SIGUSR2);
sigaddset(&block_signals, SIGINT);
sigaddset(&block_signals, SIGTERM);
+ sigaddset(&block_signals, SIGCONT);
+ sigaddset(&block_signals, SIGSTOP);
+ sigaddset(&block_signals, SIGTSTP);
sigprocmask(SIG_BLOCK, &block_signals, NULL);
/* Allow Ctrl-Alt-Del to reboot system. */
@@ -726,6 +733,27 @@ static void ctrlaltdel_signal(int sig)
run_actions(CTRLALTDEL);
}
+/*
+ * The SIGSTOP & SIGTSTP handler
+ */
+static void stop_handler(int sig)
+{
+ int saved_errno = errno;
+
+ got_cont = 0;
+ while(!got_cont) pause();
+ got_cont = 0;
+ errno = saved_errno;
+}
+
+/*
+ * The SIGCONT handler
+ */
+static void cont_handler(int sig)
+{
+ got_cont = 1;
+}
+
#endif /* ! DEBUG_INIT */
static void new_initAction(initActionEnum action, char *process, char *cons)
@@ -925,6 +953,9 @@ extern int init_main(int argc, char **argv)
signal(SIGUSR2, halt_signal);
signal(SIGINT, ctrlaltdel_signal);
signal(SIGTERM, reboot_signal);
+ signal(SIGCONT, cont_handler);
+ signal(SIGSTOP, stop_handler);
+ signal(SIGTSTP, stop_handler);
/* Turn off rebooting via CTL-ALT-DEL -- we get a
* SIGINT on CAD so we can shut things down gracefully... */