[CRIU] [PATCH 4/4] p.haul: work around process name caching in psutil
Adrian Reber
adrian at lisas.de
Tue Oct 20 08:20:33 PDT 2015
From: Adrian Reber <areber at redhat.com>
The python module psutil caches the process name so that sometimes
restored process have 'criu' as the process name. psutil uses the
process' PID and start time to decide if the process name has to be
updated. But as the start time does not change it will sometimes not
change to the restored process name but it will keep listing the restore
process as 'criu'. This is now fixed in upstream psutil but will
probably take some time to be available in distribution packages.
Signed-off-by: Adrian Reber <areber at redhat.com>
---
webgui/procs.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/webgui/procs.py b/webgui/procs.py
index 354a5aa..662b7f6 100644
--- a/webgui/procs.py
+++ b/webgui/procs.py
@@ -43,10 +43,19 @@ def procs():
root = {}
for p in psutil.process_iter():
+ if callable(p.cmdline):
+ name = os.path.basename(p.cmdline()[0])
+ if name is '':
+ name = p.name()
+ else:
+ try:
+ name = os.path.basename(p.cmdline[0])
+ except:
+ name = p.name
proc = {
# name and ppid are either functions or variables in
# different versions of psutil.
- "name": p.name() if callable(p.name) else p.name,
+ "name": name,
"id": p.pid,
"parent": p.ppid() if callable(p.ppid) else p.ppid,
"children": [],
--
1.8.3.1
More information about the CRIU
mailing list