commit:     c84ebb94d19ca856fe064e15d2068d5671e360c9
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Wed Nov 29 20:10:39 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Nov 29 20:10:39 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c84ebb94

start-stop-daemon: properly handle missing pidfile

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

 src/rc/start-stop-daemon.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index e98f8ba3..54b89b2a 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -657,8 +657,15 @@ int main(int argc, char **argv)
                        parse_schedule(applet, "0", sig);
                else
                        parse_schedule(applet, NULL, sig);
+               if (pidfile) {
+                       pid = get_pid(applet, pidfile);
+                       if (pid == -1)
+                               exit(EXIT_FAILURE);
+               } else {
+                       pid = 0;
+               }
                i = run_stop_schedule(applet, exec, (const char *const *)margv,
-                   get_pid(applet, pidfile), uid, test, progress, false);
+                   pid, uid, test, progress, false);
 
                if (i < 0)
                        /* We failed to stop something */

Reply via email to