Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 160022

Summary: daemon() in /etc/rc.d/init.d/functions returns incorrect value with --check option
Product: Red Hat Enterprise Linux 3 Reporter: Kai-Min Sung <kai>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED WONTFIX QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-06-10 18:54:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
Patch for /etc/rc.d/init.d/functions none

Description Kai-Min Sung 2005-06-10 02:54:50 UTC
Description of problem:
The daemon() function in the file /etc/rc.d/init.d/functions is called by 
several init scripts to startup daemon processes. On success, this function 
prints "OK" to screen and returns the value 0. On failure, this function 
prints "FAILED" to screen and returns the value 1.

The --check option can be used to specify a pid file in the /var/run directory 
to check if a process with that pid is still running. If the --check option is 
specified and the process is still alive, the daemon() function silently 
calls "return" with no argument, which results in a return value of 0 
(success) in this case.

I believe the correct return value in this situation should be 1 (failure), 
since it is considered an error when trying to startup a daemon process that 
is still running. Furthermore, before returning from this failure the function 
should print to screen "FAILED".

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Create an init script which calls "daemon --check program" on startup
2. Run the init script twice to startup the program
Actual results:
The second time the init script is run, the daemon function returns success 
but no "OK" or "FAILED" message is printed to screen.

Expected results:
The daemon function should return false the second time it is run and 
print "FAILED" to screen.

Additional info:
Attached is a patch for how I'd fix the issue

Comment 1 Kai-Min Sung 2005-06-10 02:54:51 UTC
Created attachment 115281 [details]
Patch for /etc/rc.d/init.d/functions

Comment 2 Bill Nottingham 2005-06-10 18:54:55 UTC
At this point, that's expected behavior; this isn't something we'd change for