aboutsummaryrefslogtreecommitdiff
path: root/src/runscript.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-08 16:03:48 +0000
committerRoy Marples <roy@marples.name>2007-04-08 16:03:48 +0000
commit6e2ef07dd32af0a672266401bad550a072ff0443 (patch)
tree932a36f32dcf6826d74527ac54168dbba2a049cc /src/runscript.c
parenta66136655e918ae02ccf2561dc62d4884ff39f5a (diff)
LIBDIR -> LIB. When interuppted, ensure service state is restored correctly. When stopping, don't uncoldplug too early.
Diffstat (limited to 'src/runscript.c')
-rw-r--r--src/runscript.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/runscript.c b/src/runscript.c
index 9a761482..d87d42f0 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -231,19 +231,21 @@ static void cleanup (void)
{
if (rc_service_state (applet, rc_service_wasinactive))
rc_mark_service (applet, rc_service_inactive);
- else
+ else
rc_mark_service (applet, rc_service_stopped);
}
else if (rc_service_state (applet, rc_service_stopping))
{
/* If the we're shutting down, do it cleanly */
- if ((softlevel && rc_runlevel_stopping () &&
+ if ((softlevel &&
+ rc_runlevel_stopping () &&
(strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 ||
- strcmp (softlevel, RC_LEVEL_REBOOT) == 0)) ||
- ! rc_service_state (applet, rc_service_wasinactive))
+ strcmp (softlevel, RC_LEVEL_REBOOT) == 0)))
rc_mark_service (applet, rc_service_stopped);
- else
+ else if (rc_service_state (applet, rc_service_wasinactive))
rc_mark_service (applet, rc_service_inactive);
+ else
+ rc_mark_service (applet, rc_service_started);
}
if (exclusive && rc_exists (exclusive))
unlink (exclusive);
@@ -1049,11 +1051,14 @@ int main (int argc, char **argv)
{
if (in_background)
get_started_services ();
- else if (! rc_runlevel_stopping ())
- uncoldplug (applet);
svc_stop (service, deps);
+ if (! in_background &&
+ ! rc_runlevel_stopping () &&
+ rc_service_state (service, rc_service_stopped))
+ uncoldplug (applet);
+
if (in_background &&
rc_service_state (service, rc_service_inactive))
{
@@ -1069,7 +1074,7 @@ int main (int argc, char **argv)
einfo ("Manually resetting %s to stopped state", applet);
rc_mark_service (applet, rc_service_stopped);
uncoldplug (applet);
- }
+ }
else if (strcmp (argv[i], "help") == 0)
{
execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, "help", (char *) NULL);