开发者

kill a process in windows python 2.5

How do i kill a process in windows (xp 32开发者_JAVA百科 bits) in python 2.5? Someone on stackoverlow posted on how to import ctypes and do it but I don't have a ctypes module.

I am running the process in the following way-

ex=Execution(cmd)
#do something
ex.proc.kill() 

This gives me an error saying Popen object has no attribute kill. Using os.kill(ex.pid, signal.SIGKILL) gives a similar error.


Among others, I found two ways:

  • http://metazin.wordpress.com/2008/08/09/how-to-kill-a-process-in-windows-using-python/
  • https://blogs.oracle.com/rajkumar/entry/how_to_kill_a_process

The latter uses the subprocess module in conjunction with taskkill. The former win32api.TerminateProcess.


Popen.kill() is only available after Python 2.6. For 2.5 and earlier, you can use taskkill or the win32api as mentioned by "The MYYN".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜