Catch exception in call to psutil .cmdline() (#413)
There's a race condition where processes might disappear while filtering. The uncaught exception causes a crash.
This commit is contained in:
parent
7b81b4aa30
commit
f67e909b59
|
@ -1175,8 +1175,12 @@ def is_running(program, argument):
|
|||
# iterate over all processes found by psutil
|
||||
# and find the one with name and args passed to the function
|
||||
for p in psutil.process_iter():
|
||||
for s in filter(lambda x: program in x, p.cmdline()):
|
||||
if argument in p.cmdline():
|
||||
try:
|
||||
cmd = p.cmdline();
|
||||
except:
|
||||
continue
|
||||
for s in filter(lambda x: program in x, cmd):
|
||||
if argument in cmd:
|
||||
return True
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue