From a5ba34ec151e4e18d7b732dac1517d21a1df3710 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 20 Apr 2007 15:02:13 +0000 Subject: Fix rc-abort to notify the plugins we are aborting --- src/rc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/rc.c') 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); -- cgit v1.2.3