[Spambayes] how to kill process on Windows started with os.spawn?

Mark Hammond mhammond@skippinet.com.au
Wed Nov 27 21:20:35 2002

> I'm trying to coax pop3proxy into running an ssh command in the 
> background,
> so my pop sessions can tunnel through an encrypted channel.  On Unix (and
> MacOSX) this looks like it will be a breeze.
> If I start a process in the background like so:
>     pid = os.spawnvp(os.P_NOWAIT, cmd, args)
> on Unix systems I can later execute
>     os.kill(pid, signal.SIGHUP)
> According to the docs, on Windows systems, a process handle is 
> returned from
> os.spawn*.  How would I kill that process on Windows, since (once again,
> according to the docs), os.kill is only available on Unix systems?

This worked for me just then:

>>> os.spawnl(os.P_NOWAIT, "f:\\windows\\notepad.exe")
>>> import win32api
>>> win32api.TerminateProcess(548,0)

And sure enough, notepad was killed.

I don't know of a way without the win32api extensions.


More information about the Spambayes mailing list