Bug 201317 - pidof matches symlinks
Summary: pidof matches symlinks
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: SysVinit
Version: 4.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Bill Nottingham
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-08-04 10:59 UTC by Ingvar Hagelund
Modified: 2014-03-17 03:01 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-12-08 20:13:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Ingvar Hagelund 2006-08-04 10:59:16 UTC
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)

How reproducible:
Always

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.
  
Actual results:
All httpd, including the system's standard httpd, processes dies. Sad sysadmin.

Expected results:
Only the local service should die

Additional info:
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.

Comment 1 Bill Nottingham 2008-12-08 20:13:33 UTC
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.


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