代码如下:
import osimport signalimport subprocessimport platformdef kill_appium_for_Liunx(): p = subprocess.Popen(['ps','-A'],stdout=subprocess.PIPE) out,err = p.communicate() for line in out.splitlines(): if 'node' in line: pid = int(line.split(None,1)[0]) os.kill(pid,signal.SIGKILL)
备注:
os.kill(pid,signal.SIGKILL) 和kill -9是一样的