From f95e0b2c3e0192b44d6ac792f40a61a34f8c8b13 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 19 Feb 2008 10:18:26 +0000 Subject: [PATCH] We should remove stale pidfiles and service daemon info if we didn't find anything to stop, bug #25. --- src/rc/start-stop-daemon.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index d523b7c0..057901e0 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -789,11 +789,18 @@ int start_stop_daemon (int argc, char **argv) result = run_stop_schedule ((const char *const *)argv, cmd, pidfile, uid, quiet, verbose, test); + + if (result < 0) + /* We failed to stop something */ + exit (EXIT_FAILURE); + if (test || oknodo) return (result > 0 ? EXIT_SUCCESS : EXIT_FAILURE); - if (result < 1) - exit (result == 0 ? EXIT_SUCCESS : EXIT_FAILURE); + /* Even if we have not actually killed anything, we should + * remove information about it as it may have unexpectedly + * crashed out. We should also return success as the end + * result would be the same. */ if (pidfile && exists (pidfile)) unlink (pidfile);