Bug 592956 - pidof sometimes reports an error message unexpectedly.
Summary: pidof sometimes reports an error message unexpectedly.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: SysVinit
Version: 5.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Petr Lautrbach
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks: 814132 814136 853081
TreeView+ depends on / blocked
 
Reported: 2010-05-17 13:19 UTC by Tomas Smetana
Modified: 2018-11-14 20:07 UTC (History)
6 users (show)

Fixed In Version: SysVinit-2.86-16.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 814132 853081 (view as bug list)
Environment:
Last Closed: 2011-07-21 11:00:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed patch (434 bytes, patch)
2010-05-17 13:21 UTC, Tomas Smetana
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1040 0 normal SHIPPED_LIVE SysVinit bug fix update 2011-07-20 15:43:51 UTC

Description Tomas Smetana 2010-05-17 13:19:44 UTC
Description of problem:
pidof sometimes reports either of the following error messages unexpectedly:

 - "can't get program name from /proc/<pid>/stat"
 - "can't read sid from /proc/<pid>/stat"

Version-Release number of selected component (if applicable):
SysVinit-2.86-15.el5

How reproducible:
Sometimes

Steps to Reproduce:
1. Create a script which freqently spawns and reaps processes, e.g.:
#!/bin/bash
 
 function dummyproc()
 {
     while true
     do
         /bin/true &
     done
 }
 
 for i in `seq 1 1 10`
 do
     dummyproc &
 done
 
 wait

2. Start it in the background:
./test.sh &

3. run pidof of some daemon in the loop, and observe.
while true; do pidof syslogd > /dev/null; done
  
Actual results:
From time to time an error message like this is printed out:
pidof: can't get program name from /proc/6072/stat

Expected results:
No error messages.

Additional info:
There seems to be bug in the killall5 code causing this: killall5 uses fopen to open /proc/<pid>/stat and then freads from it.  It may happen that the file disppears between fopen and fread and this situation is not being addressed anyhow.

Comment 1 Tomas Smetana 2010-05-17 13:21:48 UTC
Created attachment 414544 [details]
Proposed patch

Let's check what we fgets from the file and give up if it's NULL ('\0').

Comment 4 RHEL Program Management 2010-08-09 19:31:47 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 11 errata-xmlrpc 2011-07-21 11:00:49 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1040.html


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