Killing a process under Windows NT/2K

Tavis Rudd tavis at calrudd.com
Fri Apr 26 20:46:59 EDT 2002


Syver Enstad (syver-en+usenet at online.no) wrote:
> mrenxo at mail.com (Enxo) wrote: 
> > I need to kill a process under Windows (NT/2K), whose PID is known.
> > Unfortunately os.kill() doesn't work under Windows.
> > How can I achieve this anyway?
> 
> Try this:
> 
>       import win32process
>       import win32api
>       import win32con
>                
>       pid = win32api.GetCurrentProcessId()  
>       handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, pid)
>       win32process.TerminateProcess(handle, 1)

Is this a hard kill (like kill -9) or a soft kill that triggers the
appropriate signal handler inside the process?

Cheers,
Tavis



More information about the Python-list mailing list