Bug 592956

Summary: pidof sometimes reports an error message unexpectedly.
Product: Red Hat Enterprise Linux 5 Reporter: Tomas Smetana <tsmetana>
Component: SysVinitAssignee: Petr Lautrbach <plautrba>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: azelinka, jscotka, rdassen, rvokal, spoyarek, tnagata
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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 11:00:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 814132, 814136, 853081    
Attachments:
Description Flags
Proposed patch none

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