Bug 592956 - pidof sometimes reports an error message unexpectedly.
pidof sometimes reports an error message unexpectedly.
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: SysVinit (Show other bugs)
5.4
All Linux
medium Severity medium
: rc
: ---
Assigned To: Petr Lautrbach
qe-baseos-daemons
:
Depends On:
Blocks: 814132 814136 853081
  Show dependency treegraph
 
Reported: 2010-05-17 09:19 EDT by Tomas Smetana
Modified: 2013-06-24 02:26 EDT (History)
6 users (show)

See Also:
Fixed In Version: SysVinit-2.86-16.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 814132 853081 (view as bug list)
Environment:
Last Closed: 2011-07-21 07:00:49 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Tomas Smetana 2010-05-17 09:19:44 EDT
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 09:21:48 EDT
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 Product and Program Management 2010-08-09 15:31:47 EDT
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 07:00:49 EDT
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.