[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#668958: lsb-base: pidofproc doesn't return correct status for daemons without pidfile



Package: lsb-base
Version: 4.1+Debian0
Severity: normal

Hi.

I noticed that "/etc/init.d/hddtemp status" wasn't returning the correct
status when the daemon was running. hddtemp daemon doesn't create a pidfile
when started, so I tracked the problem back to the pidofproc function
from /lib/lsb/init-functions.

Basically I put the section with "if [ -x /bin/pidof ] && [ !
"$specified" ]; then" before the section with "base=${1##*/}". Now the
function is corectly detecting the pids and "/etc/init.d/hddtemp status"
gives the right information. Please check the attached patch. I also
tested the other daemons on my system, both with pidfiles and without
and all seem to work fine.

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-2-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

-- no debconf information

-- debsums errors found:
debsums: changed file /lib/lsb/init-functions (from lsb-base package)
--- /lib/lsb/init-functions	2012-04-16 04:22:23.000000000 +0300
+++ /home/adrian/init-functions	2012-03-26 12:13:49.000000000 +0300
@@ -76,19 +76,11 @@
     done
     shift $(($OPTIND - 1))
 
-    if [ -x /bin/pidof ] && [ ! "$specified" ]; then
-        status="0"
-        /bin/pidof -o %PPID -x $1 || status="$?"
-        if [ "$status" = 1 ]; then
-            return 3 # program is not running
-        fi
-        return 0
-    fi
-
     base=${1##*/}
     if [ ! "$specified" ]; then
         pidfile="/var/run/$base.pid"
     fi
+
     if [ -n "${pidfile:-}" ]; then
      if [ -e "$pidfile" ]; then
       if [ -r "$pidfile" ]; then
@@ -111,6 +103,14 @@
        return 3 # pid file doesn't exist, program probably stopped
      fi
     fi
+    if [ -x /bin/pidof ] && [ ! "$specified" ]; then
+        status="0"
+        /bin/pidof -o %PPID -x $1 || status="$?"
+        if [ "$status" = 1 ]; then
+            return 3 # program is not running
+        fi
+        return 0
+    fi
     if [ "$specified" ]; then
         return 3 # almost certain it's not running
     fi

Reply to: