Skip to content

Commit

Permalink
p.haul: work around process name caching in psutil
Browse files Browse the repository at this point in the history
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 tracked at:

 giampaolo/psutil#692

Signed-off-by: Adrian Reber <areber@redhat.com>
  • Loading branch information
adrianreber committed Oct 16, 2015
1 parent 4c35bfe commit c91538f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion webgui/procs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ def GET(self):
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": [],
Expand Down

0 comments on commit c91538f

Please sign in to comment.