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):
Steps to Reproduce:
1. Create a script which freqently spawns and reaps processes, e.g.:
for i in `seq 1 1 10`
2. Start it in the background:
3. run pidof of some daemon in the loop, and observe.
while true; do pidof syslogd > /dev/null; done
From time to time an error message like this is printed out:
pidof: can't get program name from /proc/6072/stat
No error messages.
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.
Created attachment 414544 [details]
Let's check what we fgets from the file and give up if it's NULL ('\0').
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.
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.