commit:     0200002b8cbd061ac79b6aed4024220cd0386d2c
Author:     Andrey Utkin <andrey_utkin <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 21 22:13:15 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed May  2 18:42:59 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0200002b

start-stop-daemon: don't fail stopping if pidfile is gone

If pidfile does not exist when we are stopping the daemon, assume it is
already stopped, and report success.

hostapd is an example of a daemon which removes its pidfile when it is
exiting. If this daemon terminates prematurely, that is, without s-s-d
involvement, then openrc fails to restart it, because s-s-d "stop"
command fails when pidfile is missing.

X-Gentoo-Bug: 646274
X-Gentoo-Bug-URL: https://bugs.gentoo.org/646274

 src/rc/start-stop-daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 1b565829..0b3b423f 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -661,7 +661,7 @@ int main(int argc, char **argv)
                        parse_schedule(applet, NULL, sig);
                if (pidfile) {
                        pid = get_pid(applet, pidfile);
-                       if (pid == -1)
+                       if (pid == -1 && errno != ENOENT)
                                exit(EXIT_FAILURE);
                } else {
                        pid = 0;

Reply via email to