Red Hat Bugzilla – Bug 201317
pidof matches symlinks
Last modified: 2014-03-16 23:01:14 EDT
Description of problem:
pidof matches symlinks. Should not be so, or at least should be documented.
Version-Release number of selected component (if applicable):
2.85-34.3 (but probably others as well)
Steps to Reproduce (or the way we found out):
1. Set up a local version of a system service like httpd, say
/usr/local/sbin/httpd81, a symlink to /usr/sbin/httpd, with it's own
/etc/httpd81, /etc/sysconfig/httpd81, /etc/init.d/httpd81, cloned and adjusted
from the system scripts
2. Start (system) httpd, start (local) httpd81 with the service command
3. Stop the (local) httpd81 with the service command.
All httpd, including the system's standard httpd, processes dies. Sad sysadmin.
Only the local service should die
This is caused by pidof, as the system script uses the function killproc, which
in turn uses pidof to localize pids when the pidfile is nonexisting or empty
# pgrep httpd81 | wc
0 0 0
# pgrep httpd | wc
31 31 186
# pidof /usr/local/sbin/httpd81 | wc # This is imho clearly wrong
1 31 186
This seems to be because pidof follows symlinks. If this is a "feature", I think
it should be noted in the manpage.
Also note that pidof operates the (my) expected way if running as a non-root
user. Beats me why.
Copying or hardlinking the binary instead of symlinking resolves the problem.
Apologies for the extreme delay in handling this. Given that the executable for running processes is determined by readlink() of /proc/$PID/exe, this behavior is expected and unavoidable.
I'm doucmenting this behavior in the manage page in our development version; furthermore, the current Fedora release (F10) checks pid files before pidof when stopping programs, so the problem should be fixable on that end for any services started in this way.
Closing as WONTFIX for RHEL 4; the man page change will go into RHEL 6.