34 lines
1.1 KiB
Diff
34 lines
1.1 KiB
Diff
|
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
|
||
|
|