import python-linux-procfs-0.6.3-3.el8
This commit is contained in:
parent
9024bc57c0
commit
fdd7a57519
@ -0,0 +1,33 @@
|
|||||||
|
From 7570fc0d6082cb476c32233c2904214dd57737a8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: John Kacur <jkacur@redhat.com>
|
||||||
|
Date: Fri, 19 Nov 2021 16:03:22 -0500
|
||||||
|
Subject: [PATCH] python-linux-procfs: Fix traceback with non-utf8 chars in the
|
||||||
|
/proc/PID/cmdline
|
||||||
|
|
||||||
|
Fix traceback if there are non-utf8 characters in the /proc/PID/cmdline
|
||||||
|
|
||||||
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
||||||
|
---
|
||||||
|
procfs/procfs.py | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/procfs/procfs.py b/procfs/procfs.py
|
||||||
|
index 3b7474cccb01..408b2bcd0a31 100755
|
||||||
|
--- a/procfs/procfs.py
|
||||||
|
+++ b/procfs/procfs.py
|
||||||
|
@@ -357,9 +357,9 @@ class process:
|
||||||
|
return hasattr(self, attr)
|
||||||
|
|
||||||
|
def load_cmdline(self):
|
||||||
|
- f = open("/proc/%d/cmdline" % self.pid)
|
||||||
|
- self.cmdline = f.readline().strip().split('\0')[:-1]
|
||||||
|
- f.close()
|
||||||
|
+ with open("/proc/%d/cmdline" % self.pid, mode='rb') as f:
|
||||||
|
+ cmdline = f.readline().decode(encoding='unicode_escape')
|
||||||
|
+ self.cmdline = cmdline.strip().split('\0')[:-1]
|
||||||
|
|
||||||
|
def load_threads(self):
|
||||||
|
self.threads = pidstats("/proc/%d/task/" % self.pid)
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -0,0 +1,68 @@
|
|||||||
|
From b7ea06b21456d465f2d9d11358fb803eb277357f Mon Sep 17 00:00:00 2001
|
||||||
|
From: John Kacur <jkacur@redhat.com>
|
||||||
|
Date: Tue, 23 Nov 2021 09:58:58 -0500
|
||||||
|
Subject: [PATCH 1/3] python-linux-procfs: Propagate error to user if a pid is
|
||||||
|
completed
|
||||||
|
|
||||||
|
If a pid is completed and disappears a FileNotFoundError will occur
|
||||||
|
because /proc/pid/stat will disappear too.
|
||||||
|
|
||||||
|
It is not possible to check for the file first because it could still
|
||||||
|
disappear between the time of the check and the time of use.
|
||||||
|
|
||||||
|
Propagate this error to the user.
|
||||||
|
The user should handle this with a try, except clause and ignore it if
|
||||||
|
an exception occurs.
|
||||||
|
|
||||||
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
||||||
|
---
|
||||||
|
procfs/procfs.py | 19 ++++++++++++++++---
|
||||||
|
1 file changed, 16 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/procfs/procfs.py b/procfs/procfs.py
|
||||||
|
index 408b2bcd0a31..a0e9977214fe 100755
|
||||||
|
--- a/procfs/procfs.py
|
||||||
|
+++ b/procfs/procfs.py
|
||||||
|
@@ -130,7 +130,12 @@ class pidstat:
|
||||||
|
|
||||||
|
def __init__(self, pid, basedir="/proc"):
|
||||||
|
self.pid = pid
|
||||||
|
- self.load(basedir)
|
||||||
|
+ try:
|
||||||
|
+ self.load(basedir)
|
||||||
|
+ except FileNotFoundError:
|
||||||
|
+ # The file representing the pid has disappeared
|
||||||
|
+ # propagate the error to the user to handle
|
||||||
|
+ raise
|
||||||
|
|
||||||
|
def __getitem__(self, fieldname):
|
||||||
|
return self.fields[fieldname]
|
||||||
|
@@ -151,7 +156,11 @@ class pidstat:
|
||||||
|
return fieldname in self.fields
|
||||||
|
|
||||||
|
def load(self, basedir="/proc"):
|
||||||
|
- f = open("%s/%d/stat" % (basedir, self.pid))
|
||||||
|
+ try:
|
||||||
|
+ f = open("%s/%d/stat" % (basedir, self.pid))
|
||||||
|
+ except FileNotFoundError:
|
||||||
|
+ # The pid has disappeared, propagate the error
|
||||||
|
+ raise
|
||||||
|
fields = f.readline().strip().split(') ')
|
||||||
|
f.close()
|
||||||
|
fields = fields[0].split(' (') + fields[1].split()
|
||||||
|
@@ -338,7 +347,11 @@ class process:
|
||||||
|
else:
|
||||||
|
sclass = pidstatus
|
||||||
|
|
||||||
|
- setattr(self, attr, sclass(self.pid, self.basedir))
|
||||||
|
+ try:
|
||||||
|
+ setattr(self, attr, sclass(self.pid, self.basedir))
|
||||||
|
+ except FileNotFoundError:
|
||||||
|
+ # The pid has disappeared, progate the error
|
||||||
|
+ raise
|
||||||
|
elif attr == "cmdline":
|
||||||
|
self.load_cmdline()
|
||||||
|
elif attr == "threads":
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -0,0 +1,50 @@
|
|||||||
|
From eb984b30e325bbf27844bf9c1f90767504468db5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: John Kacur <jkacur@redhat.com>
|
||||||
|
Date: Tue, 23 Nov 2021 13:01:05 -0500
|
||||||
|
Subject: [PATCH 2/3] python-linux-procfs: pflags: Handle pids that completed
|
||||||
|
|
||||||
|
Sometimes pids disappear when they are completed.
|
||||||
|
|
||||||
|
Programs such as pflags that use procfs must account for that.
|
||||||
|
The solution is to simply recognize this situation, and to continue.
|
||||||
|
|
||||||
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
||||||
|
---
|
||||||
|
pflags | 15 +++++++++++++--
|
||||||
|
1 file changed, 13 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pflags b/pflags
|
||||||
|
index 3407b6f51c96..46d396c87c2b 100755
|
||||||
|
--- a/pflags
|
||||||
|
+++ b/pflags
|
||||||
|
@@ -50,14 +50,25 @@ def main(argv):
|
||||||
|
pids = list(ps.processes.keys())
|
||||||
|
|
||||||
|
pids.sort()
|
||||||
|
- len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps]
|
||||||
|
+ len_comms = []
|
||||||
|
+ for pid in pids:
|
||||||
|
+ if pid in ps:
|
||||||
|
+ try:
|
||||||
|
+ len(ps[pid]["stat"]["comm"])
|
||||||
|
+ except (TypeError, FileNotFoundError):
|
||||||
|
+ continue
|
||||||
|
+ len_comms.append(len(ps[pid]["stat"]["comm"]))
|
||||||
|
+
|
||||||
|
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()
|
||||||
|
+ try:
|
||||||
|
+ flags = ps[pid].stat.process_flags()
|
||||||
|
+ except AttributeError:
|
||||||
|
+ continue
|
||||||
|
# Remove flags that were superseeded
|
||||||
|
if "PF_THREAD_BOUND" in flags and "PF_NO_SETAFFINITY" in flags:
|
||||||
|
flags.remove("PF_THREAD_BOUND")
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
Name: python-linux-procfs
|
Name: python-linux-procfs
|
||||||
Version: 0.6.3
|
Version: 0.6.3
|
||||||
Release: 1%{?dist}
|
Release: 3%{?dist}
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
Summary: Linux /proc abstraction classes
|
Summary: Linux /proc abstraction classes
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
@ -15,6 +15,9 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
|||||||
Abstractions to extract information from the Linux kernel /proc files.
|
Abstractions to extract information from the Linux kernel /proc files.
|
||||||
|
|
||||||
# PATCHES
|
# PATCHES
|
||||||
|
Patch1: python-linux-procfs-Fix-traceback-with-non-utf8-char.patch
|
||||||
|
Patch2: python-linux-procfs-Propagate-error-to-user-if-a-pid.patch
|
||||||
|
Patch3: python-linux-procfs-pflags-Handle-pids-that-complete.patch
|
||||||
|
|
||||||
%description %_description
|
%description %_description
|
||||||
|
|
||||||
@ -45,6 +48,15 @@ rm -rf %{buildroot}
|
|||||||
%license COPYING
|
%license COPYING
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 23 2021 John Kacur <jkacur@redhat.com> - 0.6.3-3
|
||||||
|
- Propagate error to user if pid completed
|
||||||
|
- Handle pid completed in pflags
|
||||||
|
Resolves: rhbz#1820709
|
||||||
|
|
||||||
|
* Fri Nov 19 2021 John Kacur <jkacur@redhat.com> - 0.6.3-2
|
||||||
|
- Fix traceback with non-utf8 chars
|
||||||
|
Resolves: rhbz#2016204
|
||||||
|
|
||||||
* Tue Jan 12 2021 John Kacur <jkacur@redhat.com> - 0.6.3-1
|
* Tue Jan 12 2021 John Kacur <jkacur@redhat.com> - 0.6.3-1
|
||||||
- Rebase to latest upstream
|
- Rebase to latest upstream
|
||||||
- Correct URL and Source
|
- Correct URL and Source
|
||||||
|
Loading…
Reference in New Issue
Block a user