[Twisted-Python] Problems with signalProcess on Windows

Jean-Paul Calderone exarkun at divmod.com
Fri Feb 6 14:04:02 EST 2009

On Fri, 6 Feb 2009 18:40:10 +0000, Brian Granger <ellisonbg.net at gmail.com> wrote:
>[take a deep breath and try to get over how much I dislike Windows]
>So, I am using Twisted's external process capabilities in a
>cross-platform setting.  Almost everything is working now in Windows.
>But, when I try to stop the external program (using
>signalProcess("INT")) that I starting using reactor.spawnProcess, I
>get the following traceback:
>            self.process_transport.signalProcess(sig)
>          File "C:\Python25\lib\site-packages\twisted\internet\_dumbwin32proc.py
>", line 247, in signalProcess
>            win32process.TerminateProcess(self.hProcess, 1)
>        pywintypes.error: (5, 'TerminateProcess', 'Access is denied.')
>The odd thing is that the process stops just fine.  That is, it tells
>me that it has received SIGINT and is shutting down.
>Any thoughts on why this would happen?  I have no idea where to even
>begin looking.
>Thanks in advanced.

I think this is a long standing problem with Twisted's support of processes
on Windows.  I thought there was a ticket for this, but it seems the closest
thing I can find is <http://twistedmatrix.com/trac/ticket/2726>, the scope
of which is a bit broader than just making signalProcess work.

It has been suggested that it is necessary to first OpenProcess to get a
handle to pass to TerminateProcess.  The only reason this hasn't been
implemented is lack of interest (and, as you alluded, the unpleasantness
of doing anything related to Windows).


More information about the Twisted-Python mailing list