You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
5 years ago
|
From e153f5177e1ae4b7859454a2d3011d6f55710600 Mon Sep 17 00:00:00 2001
|
||
|
From: John Kacur <jkacur@redhat.com>
|
||
|
Date: Mon, 3 Dec 2018 09:02:34 -0500
|
||
|
Subject: [PATCH 2/2] python-linux-procfs: pflags: Ignore non-existent pids or
|
||
|
process names
|
||
|
|
||
|
If the user enters a non-existent pid or process name, skip over it.
|
||
|
|
||
|
Also, if the user enters nothing but a non-existent pid, then don't
|
||
|
calculte max_comm_len since you can't take the max of an empty list.
|
||
|
|
||
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
||
|
---
|
||
|
pflags-cmd.py | 7 +++++--
|
||
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/pflags-cmd.py b/pflags-cmd.py
|
||
|
index f180ed505977..c2627dcec14e 100755
|
||
|
--- a/pflags-cmd.py
|
||
|
+++ b/pflags-cmd.py
|
||
|
@@ -47,11 +47,14 @@ def main(argv):
|
||
|
pids = ps.processes.keys()
|
||
|
|
||
|
pids.sort()
|
||
|
- len_comms = map(lambda pid: len(ps[pid]["stat"]["comm"]), pids)
|
||
|
- max_comm_len = max(len_comms)
|
||
|
+ len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps]
|
||
|
+ if len_comms:
|
||
|
+ max_comm_len = max(len_comms)
|
||
|
del(len_comms)
|
||
|
|
||
|
for pid in pids:
|
||
|
+ if pid not in ps:
|
||
|
+ continue
|
||
|
flags = ps[pid].stat.process_flags()
|
||
|
# Remove flags that were superseeded
|
||
|
if "PF_THREAD_BOUND" in flags and "PF_NO_SETAFFINITY" in flags:
|
||
|
--
|
||
|
2.19.2
|
||
|
|