Skip to content

Commit f6f025d

Browse files
committed
Also match processes by the name of the binary
Show binary name in output rather than exe
1 parent cd690e9 commit f6f025d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def monitor_processes(self):
120120

121121
out += "[%5d] %s %s %.1f%% (%s / %s)" % (
122122
proc.pid,
123-
proc.exe_name,
123+
proc.name,
124124
fd_stale.path,
125125
progress_pcnt*100,
126126
format_size(float(fd_stale.fdinfo.pos)),

cv/procutil.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ def exe_name(self):
6060
"""Returns the basename of the exe path"""
6161
return os.path.basename(self.exe)
6262

63+
@property
64+
def name(self):
65+
try:
66+
with open('/proc/{0}/stat'.format(self.pid)) as f:
67+
return f.read().split(' ')[1].replace('(', '').replace(')', '')
68+
except (IOError, OSError):
69+
return ''
70+
6371
@property
6472
def open_files(self):
6573
"""
@@ -100,6 +108,6 @@ def procs_by_binary_name(bin_name):
100108
procs = []
101109
for pid in get_pids():
102110
proc = Process(pid)
103-
if proc.exe_name == bin_name:
111+
if proc.exe_name == bin_name or proc.name == bin_name:
104112
procs.append(proc)
105113
return procs

0 commit comments

Comments
 (0)