[Python-Dev] The os module, unix and win32

Tim Peters tim.one at comcast.net
Fri Jan 9 14:36:05 EST 2004


[Guido, on os.kill() for Windows]
> Clearly, until someone shows up with more expertise, nothing will
> happen.

We hash this out periodically here; e.g.,

http://mail.python.org/pipermail/python-dev/2002-December/030627.html

Windows wasn't designed to support clean termination of one process from
another, and there are lots of dangers.

For Zope's ZRS, I wrapped TerminateProcess() in a teensy C extension so the
ZRS test suite could kill the various Python processes it starts (hundreds
before the test suite finishes).  These are console-mode processes (no
windows), and make no use of Windows features, so the dangers are minimal in
doing TerminateProcess() on one of those.  The general case is a bottomless
pit (see the link referenced in the article referenced above for a taste).

Recent versions of Windows (not Win9x) have a new API, CreateRemoteThread(),
which allows process A to create a thread that runs in some other process
B's virtual address space, as if B had started the thread.  I read once
somewhere that this API can be used by A to execute the safer ExitProcess()
"from within" B.




More information about the Python-Dev mailing list