Bug 160022 - daemon() in /etc/rc.d/init.d/functions returns incorrect value with --check option
daemon() in /etc/rc.d/init.d/functions returns incorrect value with --check o...
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: initscripts (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
Depends On:
  Show dependency treegraph
Reported: 2005-06-09 22:54 EDT by Kai-Min Sung
Modified: 2014-03-16 22:54 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-06-10 14:54:55 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch for /etc/rc.d/init.d/functions (410 bytes, patch)
2005-06-09 22:54 EDT, Kai-Min Sung
no flags Details | Diff

  None (edit)
Description Kai-Min Sung 2005-06-09 22:54:50 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):

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-09 22:54:51 EDT
Created attachment 115281 [details]
Patch for /etc/rc.d/init.d/functions
Comment 2 Bill Nottingham 2005-06-10 14:54:55 EDT
At this point, that's expected behavior; this isn't something we'd change for

Note You need to log in before you can comment on or make changes to this bug.