我编写这段代码是为了检查“bad\u进程”是否正在运行:
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
因此,此代码可以检测iTerm是否正在运行,但safari没有成功: result with iTermresult with safari
因此,我可以使用psea | grepsafari检测safari,但我的代码没有成功。我应该用吗欧斯波本('ps ea | grep'+s)代替?safari进程的PID始终动态变化是否与我的案例有关?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐