Fix rc-abort to notify the plugins we are aborting

This commit is contained in:
Roy Marples 2007-04-20 15:02:13 +00:00
parent 7590e7b258
commit a5ba34ec15
2 changed files with 14 additions and 10 deletions

View File

@ -321,10 +321,6 @@ static char read_key (bool block)
struct termios termios; struct termios termios;
char c = 0; char c = 0;
/* This locks up rc for some reason!
* Why? it used to work fine... */
return 0;
if (! isatty (STDIN_FILENO)) if (! isatty (STDIN_FILENO))
return (false); return (false);
@ -456,6 +452,8 @@ static void handle_signal (int sig)
{ {
int serrno = errno; int serrno = errno;
char signame[10] = { '\0' }; char signame[10] = { '\0' };
char *run;
char *prev;
switch (sig) { switch (sig) {
case SIGINT: case SIGINT:
@ -474,8 +472,14 @@ static void handle_signal (int sig)
signal (SIGTERM, SIG_IGN); signal (SIGTERM, SIG_IGN);
killpg (getpgrp (), SIGTERM); killpg (getpgrp (), SIGTERM);
/* If we're in boot runlevel then change into single-user mode */ /* Notify plugins we are aborting */
if (strcmp (rc_get_runlevel (), RC_LEVEL_BOOT) == 0) 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 (); single_user ();
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
@ -557,9 +561,6 @@ int main (int argc, char **argv)
atexit (cleanup); atexit (cleanup);
newlevel = argv[0]; newlevel = argv[0];
/* Start a new process group */
setpgrp();
/* Setup a signal handler */ /* Setup a signal handler */
signal (SIGINT, handle_signal); signal (SIGINT, handle_signal);
signal (SIGQUIT, handle_signal); signal (SIGQUIT, handle_signal);

View File

@ -139,6 +139,9 @@ typedef enum
rc_hook_runlevel_start_in = 5, rc_hook_runlevel_start_in = 5,
rc_hook_runlevel_start_out = 8, rc_hook_runlevel_start_out = 8,
/* We reserved a few numbers if we need rc_runlevel_stop_now and done */ /* 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_in = 101,
rc_hook_service_stop_now, rc_hook_service_stop_now,
rc_hook_service_stop_done, rc_hook_service_stop_done,