Blame SOURCES/pflags_Ignore_non-existent_pids.patch
|
 |
1dbcf3 |
From 5b180973d90475ab32c470e568f1c786d94a9bf0 Mon Sep 17 00:00:00 2001
|
|
 |
1dbcf3 |
From: John Kacur <jkacur@redhat.com>
|
|
 |
1dbcf3 |
Date: Thu, 29 Nov 2018 15:39:22 +0100
|
|
 |
1dbcf3 |
Subject: [PATCH] python-linux-procfs: pflags: Ignore non-existent pids or
|
|
 |
1dbcf3 |
process names
|
|
 |
1dbcf3 |
|
|
 |
1dbcf3 |
If the user enters a non-existent pid or process name, skip over it,
|
|
 |
1dbcf3 |
|
|
 |
1dbcf3 |
Also, if the user enters nothing but a non-existent pid, then make sure
|
|
 |
1dbcf3 |
the max_comm_len defaults to 0 instead of generating an error.
|
|
 |
1dbcf3 |
|
|
 |
1dbcf3 |
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
 |
1dbcf3 |
---
|
|
 |
1dbcf3 |
pflags | 6 ++++--
|
|
 |
1dbcf3 |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
 |
1dbcf3 |
|
|
 |
1dbcf3 |
diff --git a/pflags b/pflags
|
|
 |
1dbcf3 |
index a1667fc06131..9c45600cc1ee 100755
|
|
 |
1dbcf3 |
--- a/pflags
|
|
 |
1dbcf3 |
+++ b/pflags
|
|
 |
1dbcf3 |
@@ -50,11 +50,13 @@ def main(argv):
|
|
 |
1dbcf3 |
pids = list(ps.processes.keys())
|
|
 |
1dbcf3 |
|
|
 |
1dbcf3 |
pids.sort()
|
|
 |
1dbcf3 |
- len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids]
|
|
 |
1dbcf3 |
- max_comm_len = max(len_comms)
|
|
 |
1dbcf3 |
+ len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps]
|
|
 |
1dbcf3 |
+ max_comm_len = max(len_comms, default=0)
|
|
 |
1dbcf3 |
del(len_comms)
|
|
 |
1dbcf3 |
|
|
 |
1dbcf3 |
for pid in pids:
|
|
 |
1dbcf3 |
+ if pid not in ps:
|
|
 |
1dbcf3 |
+ continue
|
|
 |
1dbcf3 |
flags = ps[pid].stat.process_flags()
|
|
 |
1dbcf3 |
# Remove flags that were superseeded
|
|
 |
1dbcf3 |
if "PF_THREAD_BOUND" in flags and "PF_NO_SETAFFINITY" in flags:
|
|
 |
1dbcf3 |
--
|
|
 |
1dbcf3 |
2.19.2
|
|
 |
1dbcf3 |
|