Make init-functions' status_of_proc return the LSB-documented 3 on inexistant pidfiles.
authorDidier Raboud <odyx@debian.org>
Mon, 19 Mar 2012 16:09:40 +0000 (17:09 +0100)
committerDidier Raboud <odyx@debian.org>
Mon, 19 Mar 2012 16:16:08 +0000 (17:16 +0100)
This enhances the 13f38d30a823afc5841fd17ee405c6ebff2af1ac commit by
additionally taking the potential inexistance of pidfiles into account.

Closes: #664621
Reported-by: Michael Prokop <mika@debian.org>
Signed-off-by: Didier Raboud <odyx@debian.org>
init-functions

index d5b697194406680e300dffa81f50675aebb4688b..35ed7eb02536184f22542f2842dfda58316f2855 100644 (file)
@@ -82,6 +82,7 @@ pidofproc () {
     fi
 
     if [ -n "${pidfile:-}" ]; then
+     if [ -e "$pidfile" ]; then
       if [ -r "$pidfile" ]; then
         read pid < "$pidfile"
         if [ -n "${pid:-}" ]; then
@@ -98,6 +99,9 @@ pidofproc () {
       else
         return 4 # pid file not readable, hence status is unknown.
       fi
+     else
+       return 3 # pid file doesn't exist, program probably stopped
+     fi
     fi
     if [ -x /bin/pidof ] && [ ! "$specified" ]; then
         status="0"