用python语言实现根据pid杀死相应进程
kill_process.py代码如下
代码如下 | 复制代码 |
#! /usr/bin/python # -*- coding: utf-8 -*- importos importsys importsignal defkill(pid): try: a=os.kill(pid, signal.SIGKILL) # a = os.kill(pid, signal.9) # 与上等效 print'已杀死pid为%s的进程, 返回值是:%s'%(pid, a) exceptOSError, e: print'没有如此进程!!!' if__name__=='__main__': kill(8132) |
ok, Enjoy it !!!