Skip to content

Commit

Permalink
Catch exception in call to psutil .cmdline() (#413)
Browse files Browse the repository at this point in the history
There's a race condition where processes might disappear while filtering. The uncaught exception causes a crash.
  • Loading branch information
zoitrok authored Aug 10, 2022
1 parent 7b81b4a commit f67e909
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions auto_cpufreq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f67e909

Please sign in to comment.