Bug 646875

Summary: Can incorrectly think that dhcpd is already running with pidfile existing but commandline not existing
Product: [openSUSE] openSUSE 11.3 Reporter: Frank Adcock <frank>
Component: OtherAssignee: Marius Tomaschewski <mt>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P5 - None    
Version: Final   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 11.3   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Frank Adcock 2010-10-15 03:27:38 UTC
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10

When issuing the command "service dhcpd restart" an error can occur if the pid file is in existence but the /proc/<pid>/cmdline file is not present.

In this situation the /etc/init.d/dhcpd script outputs an error message indicating that grep on line 226 can not find the specified file.

The existing line of 

if test -n "$p" && grep -qE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then

should be changed to 

if test -n "$p" -a -e /proc/$p/cmdline && grep -qE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then


The error output is:

netman:/usr/lib/nagios/plugins # service dhcpd restart
Shutting down ISC DHCPv4 4.x Server                                                                                             done
Starting ISC DHCPv4 4.x Server grep: /proc/29662/cmdline: No such file or directory
[chroot]                                                                                                                        done



Making the change removes the misleading error message.


Reproducible: Always

Steps to Reproduce:
1.service dhcpd restart
2.
3.
Actual Results:  
netman:/usr/lib/nagios/plugins # service dhcpd restart
Shutting down ISC DHCPv4 4.x Server                                                                                             done
Starting ISC DHCPv4 4.x Server grep: /proc/29662/cmdline: No such file or directory
[chroot]                                                                                                                        done


Expected Results:  
netman:/usr/lib/nagios/plugins # service dhcpd restart
Shutting down ISC DHCPv4 4.x Server                                                                                             done
Starting ISC DHCPv4 4.x Server [chroot]                                                                                         done
Comment 1 Marius Tomaschewski 2010-11-02 10:40:04 UTC
Thanks, for the report!

Fixed adding missed -s option to grep:

-                       if test -n "$p" && grep -qE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then
+                       if test -n "$p" && grep -qsE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then

in network:dhcp project and

http://download.opensuse.org/repositories/home:/mtomaschewski:/branches:/openSUSE:/11.3:/Update:/Test/