Red Hat Bugzilla – Bug 160022
daemon() in /etc/rc.d/init.d/functions returns incorrect value with --check option
Last modified: 2014-03-16 22:54:25 EDT
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):
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
The second time the init script is run, the daemon function returns success
but no "OK" or "FAILED" message is printed to screen.
The daemon function should return false the second time it is run and
print "FAILED" to screen.
Attached is a patch for how I'd fix the issue
Created attachment 115281 [details]
Patch for /etc/rc.d/init.d/functions
At this point, that's expected behavior; this isn't something we'd change for