aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-20 15:02:13 +0000
committerRoy Marples <roy@marples.name>2007-04-20 15:02:13 +0000
commita5ba34ec151e4e18d7b732dac1517d21a1df3710 (patch)
treee42e1cf3fcfe60f480407506623f9dd54d168b13
parent7590e7b258d34124f070b4cd01fa6cc7caa29920 (diff)
Fix rc-abort to notify the plugins we are aborting
-rw-r--r--src/rc.c21
-rw-r--r--src/rc.h3
2 files changed, 14 insertions, 10 deletions
diff --git a/src/rc.c b/src/rc.c
index 375800af..4910b733 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -320,11 +320,7 @@ static char read_key (bool block)
{
struct termios termios;
char c = 0;
-
- /* This locks up rc for some reason!
- * Why? it used to work fine... */
- return 0;
-
+
if (! isatty (STDIN_FILENO))
return (false);
@@ -456,6 +452,8 @@ static void handle_signal (int sig)
{
int serrno = errno;
char signame[10] = { '\0' };
+ char *run;
+ char *prev;
switch (sig) {
case SIGINT:
@@ -474,8 +472,14 @@ static void handle_signal (int sig)
signal (SIGTERM, SIG_IGN);
killpg (getpgrp (), SIGTERM);
- /* If we're in boot runlevel then change into single-user mode */
- if (strcmp (rc_get_runlevel (), RC_LEVEL_BOOT) == 0)
+ /* Notify plugins we are aborting */
+ rc_plugin_run (rc_hook_abort, "rc");
+
+ run = getenv ("RUNLEVEL");
+ prev = getenv ("PREVLEVEL");
+ /* Only drop into single user mode if we're booting */
+ if ((prev && strcmp (prev, "S") == 0) ||
+ (run && strcmp (run, "S") == 0))
single_user ();
exit (EXIT_FAILURE);
@@ -557,9 +561,6 @@ int main (int argc, char **argv)
atexit (cleanup);
newlevel = argv[0];
- /* Start a new process group */
- setpgrp();
-
/* Setup a signal handler */
signal (SIGINT, handle_signal);
signal (SIGQUIT, handle_signal);
diff --git a/src/rc.h b/src/rc.h
index 56d92eaf..aa49903e 100644
--- a/src/rc.h
+++ b/src/rc.h
@@ -139,6 +139,9 @@ typedef enum
rc_hook_runlevel_start_in = 5,
rc_hook_runlevel_start_out = 8,
/* We reserved a few numbers if we need rc_runlevel_stop_now and done */
+ rc_hook_abort = 99,
+ /* We send the abort if an init script requests we abort and drop
+ * into single user mode if system not fully booted */
rc_hook_service_stop_in = 101,
rc_hook_service_stop_now,
rc_hook_service_stop_done,