[PATCH 0/2] python-linux-procfs and pflag changes
by John Kacur
Please pick-up the following patches
You can also fetch them via git
Repo: git://git.kernel.org:/pub/scm/linux/kernel/git/jkacur/python-schedutils.git
Branch: jkacur/jkacur/rhel8-py3
John Kacur (2):
procfs: Reduce not in python3 by default
python-linux-procfs: pflags: Use argparse to create a help option
pflags | 12 +++++++++---
procfs/procfs.py | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)
--
2.19.1
4 years, 11 months
[PATCH] python-linux-procfs: pflags: Ignore non-existent pids or process names
by John Kacur
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 make sure
the max_comm_len defaults to 0 instead of generating an error.
Signed-off-by: John Kacur <jkacur(a)redhat.com>
---
pflags | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pflags b/pflags
index a1667fc06131..9c45600cc1ee 100755
--- a/pflags
+++ b/pflags
@@ -50,11 +50,13 @@ def main(argv):
pids = list(ps.processes.keys())
pids.sort()
- len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids]
- max_comm_len = max(len_comms)
+ len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps]
+ max_comm_len = max(len_comms, default=0)
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
4 years, 12 months