I'm wrote this code to check if 'bad_process' is running:
bad_process_list=['iTerm']
c = os.popen('ps ea') #'ps aux' for complicated cases
for smth in c: #make a timer to run fulltime
for s in bad_process_list:
if s in smth:
print('close ', s,' right now!')
break
so, this code can detect if iTerm running, but no luck with safari: result with iTerm result with safari
so, i can detect safari using ps ea | grep safari, but no luck with my code. should i use os.popen('ps ea | grep '+s) instead? is dynamic changing of PID of safari process alltime is associated with my case?