diff options
author | Christian Ruppert <idl0r@gentoo.org> | 2011-12-31 03:35:32 +0100 |
---|---|---|
committer | Christian Ruppert <idl0r@gentoo.org> | 2011-12-31 03:35:32 +0100 |
commit | 34b7632d1d2ed38c7251ac8c2869c8fc416a99f5 (patch) | |
tree | 4eabbdd624ca5eea6b9928e06068ea2213a3f0d0 | |
parent | fb8db18d79b4efc65c2b04a66a8e9e3b56f21f00 (diff) |
Do not exit immediately when a service has been stopped already
The old behaviour was to exit(EXIT_SUCCESS) in case the service has been stopped
already, even if further commands has been passed to the init script
(like zap, start).
So using for example /etc/init.d/foo stop zap start would abort immediately
after "stop" if the service has been stopped already. Though there may be cases
were we need it to proceed with the remaining commands, zap and start in this
case.
This patch fixes the behaviour to continue and proceed with the remaining
commands whenever necessary.
X-Gentoo-Bug: 371845
X-Gentoo-Bug-URL: https://bugs.gentoo.org/371845
-rw-r--r-- | src/rc/runscript.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rc/runscript.c b/src/rc/runscript.c index cd53b349..2f66971c 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -821,7 +821,7 @@ svc_start(void) svc_start_real(); } -static void +static int svc_stop_check(RC_SERVICE *state) { *state = rc_service_state(service); @@ -848,7 +848,7 @@ svc_stop_check(RC_SERVICE *state) if (*state & RC_SERVICE_STOPPED) { ewarn("WARNING: %s is already stopped", applet); - exit(EXIT_SUCCESS); + return 1; } rc_service_mark(service, RC_SERVICE_STOPPING); @@ -861,6 +861,8 @@ svc_stop_check(RC_SERVICE *state) else if (rc_service_in_runlevel(service, RC_LEVEL_BOOT)) ewarn("WARNING: you are stopping a boot service"); } + + return 0; } static void @@ -986,7 +988,7 @@ svc_stop_real(void) rc_plugin_run(RC_HOOK_SERVICE_STOP_OUT, applet); } -static void +static int svc_stop(void) { RC_SERVICE state; @@ -995,13 +997,16 @@ svc_stop(void) if (dry_run) einfon("stop:"); else - svc_stop_check(&state); + if (svc_stop_check(&state) == 1) + return 1; /* Service has been stopped already */ if (deps) svc_stop_deps(state); if (dry_run) printf(" %s\n", applet); else svc_stop_real(); + + return 0; } static void @@ -1351,7 +1356,8 @@ runscript(int argc, char **argv) } if (deps && in_background) get_started_services(); - svc_stop(); + if (svc_stop() == 1) + continue; /* Service has been stopped already */ if (deps) { if (!in_background && !rc_runlevel_stopping() && |