时间:2020-10-08 13:26:05 | 栏目:Python代码 | 点击:次
用python语言实现根据pid杀死相应进程
kill_process.py代码如下
#! /usr/bin/python # -*- coding: utf-8 -*- import os import sys import signal def kill(pid): try: a = os.kill(pid, signal.SIGKILL) # a = os.kill(pid, signal.9) # 与上等效 print '已杀死pid为%s的进程, 返回值是:%s' % (pid, a) except OSError, e: print '没有如此进程!!!' if __name__ == '__main__': kill(8132)
ok, Enjoy it !!!