Red Hat Bugzilla – Bug 53070
daemon() in /etc/rc.d/init.d/functions fails to detect already-running daemon instances
Last modified: 2014-03-16 22:23:13 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Description of problem:
The daemon() function within /etc/rc.d/init.d/functions attempts to
discern whether or not any instances of the specifed process are already
running. If so then it returns without further invocations. The snippet
currently looks like:
#See if it's already running. Look *only* at the pid file.
[ -n "$pid" ] && return
This snippet is erroneous in that it tests whether or not the length of
$pid is non-zero, yet it is $pidlist that is populated with existing pid
(s). Result is that running instances are never detected.
Solution is to use consistent variable naming.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Write a start-script that utilizes the daemon() function
within /etc/rc.d/init.d/functions to start up a process.
2. Run the start-script, and note the # of running instances of the
3. Run the start-script a second time, and note that 2 processes should
now be running.
Actual Results: Two instances of the process were observed to be running
after the second invocation of the start-script.
Expected Results: Only one instance of the process was expected to be
running after the second invocation of the start-script.
When I used consistent variable-naming (i.e. I changed $pid to $pidlist in
the snippet from daemon() within /etc/rc.d/init.d/functions, the expected
results were then produced.
This is fixed in the roswell initscripts.