Red Hat Bugzilla – Bug 12295
Bug in /etc/rc.d/init.d/functions not starting daemon
Last modified: 2014-03-16 22:14:16 EDT
If you write an init.d script to start a daemon - let's say it's
the foobar daemon, you will generally write an init script
Now /etc/rc.d/init.d/functions uses /sbin/pidof to try and figure out if
the daemon is already running. But now the initscript is called
foobar and the daemon is called foobar. pidof always returns true
because it confuses the fact that the initscript foobar is running
with whether the daemon foobar is running. Thus the daemon is never
started because it thinks it is already running. This didn't seem to be a
problem in RH 6.1.
To make matters more confusing running "sh /etc/rc.d/init.d/foobar" seems
to work, whereas "/etc/rc.d/initd/foobar" does not work. Who knows why.
The solution is to make sure if pidof returns a pid, make sure it is not
the pid of the init script itself. This may or may not be easy if
the daemon function is run in the background, it may not have access to the
old pid. But something needs to be done. At a very bare minimum report the
reason it's not going to run the daemon and preferably document the bug in
the script if it can't be fixed.
This appears to be fixed in the pinstripe beta; I can't
reproduce it here.