Bug 188406 - __pids_pidof() function sometimes fails to return pid
Summary: __pids_pidof() function sometimes fails to return pid
Keywords:
Status: CLOSED INSUFFICIENT_DATA
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: 5
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-04-09 06:27 UTC by Ian Laurie
Modified: 2014-03-17 02:59 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2007-09-18 19:29:13 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Ian Laurie 2006-04-09 06:27:18 UTC
Description of problem:
__pids_pidof() function in /etc/rc.d/init.d/functions fails to return the
pid if the process has a different root directory.

Version-Release number of selected component (if applicable):
initscripts-8.31.1-1

How reproducible:
Always

Steps to Reproduce:
1.  Issue command "service thttpd start"
2.  Issue command "service thttpd status"
3.  Observe bogus message "thttpd dead but pid file exists"
  
Actual results:
The __pids_pidof() in /etc/rc.d/init.d/functions sometimes fails to return
the pid of a process.  Failures happen when the process has a different
root directory.  This will ALWAYS be true with some services, for example
thttpd, since it does a chroot() !!

Expected results:
The function __pids_pidof() should always work.

Additional info:
The function looks like this:

# Output PIDs of matching processes, found using pidof
__pids_pidof() {
	pidof -c -o $$ -o $PPID -o %PPID -x "$1" || \
		pidof -c -o $$ -o $PPID -o %PPID -x "${1##*/}"
}

The cause of the problem is the '-c' option which causes the pidof
command to only return process ids that are running with the same root
directory.

Is that **really** necessary?  Why was that explicitly done?  If you get
rid of the option (as per RHEL3 & 4) it will work always.

Comment 1 MASAO TAKAHASHI 2006-07-19 02:38:15 UTC
There is a same problem in initscripts-8.35-1.1

Comment 2 Miloslav Trmač 2006-07-29 18:04:49 UTC
> Why was that explicitly done?
To avoid incorrect matches with services running in chroot installations.  Rawhide
versions also check whether the PID specified in the PID file exists before
concluding the process is dead, not only (pidof) results.

> There is a same problem in initscripts-8.35-1.1
Can you recheck, please?  This is a duplicate of #182623, which was supposed
to be fixed in initscripts-8.32.  It seems to work correctly with
initscripts-8.36-1 and thttpd-2.25b-11.fc6.

Comment 3 Bill Nottingham 2007-09-18 19:29:13 UTC
Closing, no response.


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