[Python-Dev] RE: how to kill process on Windows started with os.spawn?
Skip Montanaro
skip@pobox.com
Sun, 1 Dec 2002 07:37:03 -0600
Regarding how to kill a process on Windows which was started with os.spawn*,
on the Spambayes list I asked:
>> How would I kill that process on Windows,
Mark Hammond replied:
This worked for me just then:
>>> os.spawnl(os.P_NOWAIT, "f:\\windows\\notepad.exe")
548
>>> import win32api
>>> win32api.TerminateProcess(548,0)
Tim also replied:
Tim> For 2.3, I implemented something or other for the Python core;
Tim> probably killpid();
Shouldn't one of these solutions (or some variant) appear under the veneer
of os.kill()? I realize the semantics might not be exactly the same
(perhaps Windows solutions don't support different signals or a different
set of signals), but it seems to me that if an attempt is made to provide
the os.spawn* functions across platforms we should make a similar attempt to
provide a way to kill spawned processes as well.
Corollary question: Is there some reason the win32api stuff isn't in the
core?
Skip