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

Bug#677424: lsb-base: status_of_proc returns 4 (unknown) when pid file is specified and does not exist



Package: lsb-base
Version: 3.2-23.2squeeze1
Severity: normal
Tags: patch


The specific problem I'm experiencing is with /etc/init.d/portmap, which
returns 4 when portmap isn't running. I can't find sufficient documentation on
correct behavior to be sure if init-functions is incorrect, or if portmap is
using it incorrectly, but I think it's the former.

This actually causes serious problems at least in managing portmap with
pacemaker, which requires init scripts to comply strictly with the LSB
specification [2]. Pacemaker will call the "status" action periodically to
monitor the service, and if the response is "unknown", the monitor action is
considered to have failed, which might get the node ejected from the cluster,
or at least prevent other things from running as they should.

I think the crux of the issue is the implementation of pidofproc. The LSB
specification [1] says about pidofproc:

    "If the -p pidfile option is specified and the named pidfile does not
    exist, the functions shall assume that the daemon is not running."

At the end of pidofproc is this:

    if [ -x /bin/pidof -a ! "$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
    return 4 # Unable to determine status

The way I read this, pidofproc can't return 3 if a pidfile is specified, which
I think is wrong according to the LSB specification. As I read the spec [1], if
the pidfile doesn't exist, and it was explicitly specified, then pidofproc
should return 3. No process table grepping or anything else allowed. In that
spirit, I propose this patch, which at least solves my problem:

--- init-functions.orig 2012-06-13 16:55:02.000000000 -0400
+++ init-functions      2012-06-13 17:02:58.000000000 -0400
@@ -77,6 +77,9 @@
         pidfile="/var/run/$base.pid"
     fi

+    if [ "$specified" -a -n "${pidfile:-}" -a ! -e "$pidfile" ]; then
+        return 3 # explicitly specified pidfile does not exist; must assume not running
+    fi
     if [ -n "${pidfile:-}" -a -r "$pidfile" ]; then
         read pid < "$pidfile"
         if [ -n "${pid:-}" ]; then

-- System Information:
Debian Release: 6.0.5
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/16 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages lsb-base depends on:
ii  ncurses-bin               5.7+20100313-5 terminal-related programs and man 
ii  sed                       4.2.1-7        The GNU sed stream editor

lsb-base recommends no packages.

lsb-base suggests no packages.

-- no debconf information

[1] http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
[2] http://www.clusterlabs.org/doc/en-US/Pacemaker/1.1/html/Pacemaker_Explained/ap-lsb.html




Reply to: