Package: lsb-base
Version: 3.1-10
Severity: normal
File: /lib/lsb/init-functions
Tags: patch

So, pidofproc currently reads the pidfile and echo's the contents if
there's anything in it, without actually checking the the process is
running or not.  That's the first bug.

The second is that
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
says that the return code should be 1 if the process is dead but the
pidfile exists.  pidofproc currently exits 2, which is the return code
for a dead program but a lock file (not a pid file).

The patch below addresses both issues.

Thanks,

--- /lib/lsb/init-functions     2006-06-05 20:57:40.000000000 +0100
+++ init-functions      2006-08-06 14:40:04.000000000 +0100
@@ -74,11 +74,13 @@
     if [ -f "$pidfile" ]; then
         read pid < "$pidfile"
         if [ -n "${pid:-}" ]; then
-            echo "$pid"
-            return 0
-        else
-            return 2 # program is dead and /var/run pid file exists
-        fi
+            if $(kill -0 "${pid:-}"); then
+                    echo "$pid"
+                    return 0
+                else
+                    return 1 # program is dead and /var/run pid file exists
+                fi
+            fi
     elif [ -x /bin/pidof -a ! "$specified" ]; then
         /bin/pidof -o %PPID $1
         status="$?"


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-1-686
Locale: LANG=en_US.UTF8, LC_CTYPE=en_US.UTF8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF8)

Versions of packages lsb-base depends on:
ii  ncurses-bin                   5.5-2      Terminal-related programs and man 
ii  sed                           4.1.5-1    The GNU sed stream editor

lsb-base recommends no packages.

-- no debconf information

-- 
 -----------------------------------------------------------------
|   ,''`.                                            Stephen Gran |
|  : :' :                                        [EMAIL PROTECTED] |
|  `. `'                        Debian user, admin, and developer |
|    `-                                     http://www.debian.org |
 -----------------------------------------------------------------

Attachment: signature.asc
Description: Digital signature

Reply via email to