[Python-Dev] RE: how to kill process on Windows started with os.spawn?

Tim Peters tim.one@comcast.net
Mon, 02 Dec 2002 00:44:30 -0500


[Skip Montanaro]
> Posix.kill() wants a pid. Can't os.kill() want anything it wants?  ;-)

Yes.  On Windows it wants a handle, because that's what spawn*() returns on
Windows.  But, again, Windows processes aren't intended to be killed
externally.

> In particular, can't it test its arguments to see if it got a handle
> or a pid then "Do The Right Thing" (tm Spike Lee I think)?

No, process handles and process ids are both just "little integers" on
Windows.

> ...
> For the python-dev types not on the spambayes list, I do have an
> application in mind.  In my environment I need to tunnel SB's
> pop3proxy app through an ssh connection.  Starting and stopping
> it works okay on my MacOSX system, and I presume it will under other
> Unix-based systems.  I began thinking about whether this would port
> to other platforms and noticed that os.kill() is only supported under
> Unix.

Why do you need to kill a process externally?  For example, why can't you
make "please stop now" a part of the protocol, so that a process can
terminate itself gracefully when told to?

> It may turn out that my desire is moot if ssh can't be run under
> Windows anyway.

http://www.python.org/dev/devfaq.html#w1