Interview Questions

How do I emulate os.kill() in Windows?

Python Questions and Answers


(Continued from previous question...)

How do I emulate os.kill() in Windows?

Use win32api:

def kill(pid):
"""kill function for Win32"""
import win32api
handle = win32api.OpenProcess(1, 0, pid)
return (0 != win32api.TerminateProcess(handle, 0))

(Continued on next question...)

Other Interview Questions