killproc routine removes PID file even if HUP is sent to process.

Bug #176934 reported by David Ramsden
6
Affects Status Importance Assigned to Milestone
lsb (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: lsb-base

Whilst looking in to a bug with nagios2 (see bug #174466), I think there is a bug in the killproc() sub-routine within /lib/lsb/init-functions (from the lsb-base package). If an init script calls this sub-routine to issue a HUP siginal, the PID file is removed. For example:

killproc -p $THEPIDFILE $DAEMON 1

This causes an issue because the PID file is removed, even though a HUP is sent to the process and as a result, a future reload (e.g. /etc/init.d/nagios2 reload) causes two daemons to be spawned because the PID file has been removed so the daemon's init script believes the daemon has stopped.

Package: lsb-base
Priority: required
Section: misc
Installed-Size: 76
Maintainer: Ubuntu Core Developers <email address hidden>
Original-Maintainer: Chris Lawrence <email address hidden>
Architecture: all
Source: lsb
Version: 3.1-23.1ubuntu3
Replaces: lsb-core (<< 2.0-6), lsb (<< 2.0-6)
Depends: sed, ncurses-bin
Conflicts: lsb-core (<< 2.0-6), lsb (<< 2.0-6)
Filename: pool/main/l/lsb/lsb-base_3.1-23.1ubuntu3_all.deb
Size: 20176
MD5sum: cfcd198d912a3ac8846b58c883c9c14a
SHA1: 2dd7a35b92fb105ca4393a418dfcc869eab9b77e
SHA256: 3c3fc72e2eb258faed465ce840c6c7601ed681cecb800df0885d741f8fd87d3f
Description: Linux Standard Base 3.1 init script functionality
 The Linux Standard Base (http://www.linuxbase.org/) is a standard
 core system that third-party applications written for Linux can
 depend upon.
 .
 This package only includes the init-functions shell library, which
 may be used by other packages' initialization scripts for console
 logging and other purposes.
Bugs: mailto:<email address hidden>
Origin: Ubuntu

This was noted in gusty. Other releases have not been tested or checked.

Revision history for this message
David Ramsden (david-hexstream) wrote :

Attached is a patch that (for me) corrects the above problem in killproc() from /lib/lsb/init-functions. It checks to see what signal type was sent. If the signal type is 1 (HUP), it does not remove the PID file.

description: updated
Revision history for this message
David Ramsden (david-hexstream) wrote :

I've had a look at the lsb-base package in Debian unstable and with lsb-base 3.1-24, this bug has been fixed.

http://packages.debian.org/changelogs/pool/main/l/lsb/lsb_3.1-24/changelog
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416559

" * Don't remove the pidfile in killproc if a signal is specified; the
     specification does not specify this behavior, and it can cause
     problems with signals like HUP. (Closes: #416559)
   * And then, only remove the pidfile if the process is actually dead.
     (Closes: #410622)"

The fix in init-functions:

    if [ -z "$sig" ]; then
        pidofproc -p $pidfile "$1" >/dev/null || rm -f "$pidfile"
    fi

Revision history for this message
Albert Damen (albrt) wrote :

This was indeed fixed in lsb 3.1-24. Therefore I will mark this bug as fixed.
Unfortunately a new bug in lsb showed up: calling killproc with SIGHUP will now terminate the process. See bug 228460.

Changed in lsb:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.