summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-03-04 20:41:25 +0000
committerRoy Marples <roy@marples.name>2008-03-04 20:41:25 +0000
commit4ae5aebe81c57fa3e03a48d84d1f091b6f92a027 (patch)
tree4781918b662064a1102f22a82203195111fd7d50 /src
parentfb85a0833f7c7406fd93e96e197d0ac79c0eef22 (diff)
downloadopenrc-4ae5aebe81c57fa3e03a48d84d1f091b6f92a027.tar.gz
openrc-4ae5aebe81c57fa3e03a48d84d1f091b6f92a027.tar.bz2
openrc-4ae5aebe81c57fa3e03a48d84d1f091b6f92a027.tar.xz
Inform plugins when we exit if on signal.
Diffstat (limited to 'src')
-rw-r--r--src/rc/rc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 090d927..f547cd5 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -96,6 +96,7 @@ static char **coldplugged_services = NULL;
static char **stop_services = NULL;
static char **start_services = NULL;
static rc_depinfo_t *deptree = NULL;
+static rc_hook_t hook_out = 0;
static char *tmp = NULL;
struct termios *termios_orig = NULL;
@@ -144,6 +145,9 @@ static void cleanup (void)
if (applet && strcmp (applet, "rc") == 0) {
pidlist_t *pl = service_pids;
+ if (hook_out)
+ rc_plugin_run (hook_out, runlevel);
+
rc_plugin_unload ();
if (! rc_in_plugin && termios_orig) {
@@ -849,6 +853,7 @@ int main (int argc, char **argv)
setenv ("RC_SOFTLEVEL", newlevel, 1);
rc_plugin_run (RC_HOOK_RUNLEVEL_START_IN, newlevel);
+ hook_out = RC_HOOK_RUNLEVEL_START_OUT;
run_script (INITSH);
#ifdef __linux__
@@ -864,6 +869,7 @@ int main (int argc, char **argv)
do_coldplug ();
#endif
rc_plugin_run (RC_HOOK_RUNLEVEL_START_OUT, newlevel);
+ hook_out = 0;
if (want_interactive ())
mark_interactive ();
@@ -951,6 +957,7 @@ int main (int argc, char **argv)
} else {
rc_plugin_run (RC_HOOK_RUNLEVEL_STOP_IN, runlevel);
}
+ hook_out = RC_HOOK_RUNLEVEL_STOP_OUT;
/* Check if runlevel is valid if we're changing */
if (newlevel && strcmp (runlevel, newlevel) != 0 && ! going_down) {
@@ -1109,6 +1116,7 @@ int main (int argc, char **argv)
/* Notify the plugins we have finished */
rc_plugin_run (RC_HOOK_RUNLEVEL_STOP_OUT, runlevel);
+ hook_out = 0;
rmdir (RC_STOPPING);
@@ -1139,6 +1147,7 @@ int main (int argc, char **argv)
mkdir (RC_STARTING, 0755);
rc_plugin_run (RC_HOOK_RUNLEVEL_START_IN, runlevel);
+ hook_out = RC_HOOK_RUNLEVEL_START_OUT;
/* Re-add our coldplugged services if they stopped */
STRLIST_FOREACH (coldplugged_services, service, i)
@@ -1207,6 +1216,7 @@ interactive_option:
wait_for_services ();
rc_plugin_run (RC_HOOK_RUNLEVEL_START_OUT, runlevel);
+ hook_out = 0;
#ifdef __linux__
/* mark any services skipped as stopped */