Bug 1654311

Summary: pflags KeyError when passed a non-existent pid
Product: Red Hat Enterprise Linux 7 Reporter: John Kacur <jkacur>
Component: python-linux-procfsAssignee: John Kacur <jkacur>
Status: CLOSED ERRATA QA Contact: Qiao Zhao <qzhao>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.7CC: bhu, jkacur
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-linux-procfs-0.4.11-4.el7 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of:
: 1654312 (view as bug list) Environment:
Last Closed: 2019-08-06 12:34:28 UTC Type: Bug
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: 1649541, 1654312    
Attachments:
Description Flags
Ignore non-existent pids and process names none

Description John Kacur 2018-11-28 13:30:04 UTC
If you pass pflags a non-existent pid a KeyError is generated

For example

./pflags 2000
Traceback (most recent call last):
  File "./pflags", line 74, in <module>
    main(sys.argv)
  File "./pflags", line 53, in main
    len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids]
  File "./pflags", line 53, in <listcomp>
    len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids]
  File "/home/jkacur/src/python-linux-procfs/procfs/procfs.py", line 411, in __getitem__
    return self.processes[key]
KeyError: 2000

What should happen is that the non-existent pid should simply be ignored

Comment 2 John Kacur 2018-12-03 14:40:48 UTC
Created attachment 1510940 [details]
Ignore non-existent pids and process names

Comment 10 errata-xmlrpc 2019-08-06 12:34:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2038