[Twisted-Python] sigchld

Jason Rennie jrennie at gmail.com
Fri Feb 11 07:27:38 MST 2011


I'm in the process of porting code from Twisted 8.1 to 10.1 which needed
some custom signal handling code.  Twisted 8.1's approach to signal handling
was (as far as we could tell) too monolithic, so we chose
"installSignalHandlers=False" and wrote our own signal handling code,
installing reactor._handleSigchld so that spawnProcess would work.  Of
course, we have to change this now since #733 was fixed (
http://twistedmatrix.com/trac/ticket/733).

IIUC, (and please correct if I don't) the SIGCHLD handler installation is
performed by twisted.internet.posixbase.PosixReactorBase._handleSignals (the
"if platformType == 'posix':" block).  So, one option would be to run that
code while still using "installSignalHandlers=False".

I'm wondering if there's a better way.  What if I were to let Twisted
install signal handlers, but run my own signal handling code after the
reactor starts (using callLater(0,...)) that installs "super" handlers which
calls the Twisted handler along with any other handlers I want to run.  I'd
use signal.getsignal to get a reference to the Twisted handler(s).  Might
this work?  Or, is there an obvious flaw?  In particular, can I get the
SIGCHLD handler using signal.getsignal, then call it via my "super" handler?
 I don't need to do any special handling of SIGCHLD, so I could just leave
that signal handler alone.

All thoughts appreciated.

Thanks,

Jason

-- 
Jason Rennie
Research Scientist, ITA Software
617-714-2645
http://www.itasoftware.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20110211/9259cc18/attachment-0001.htm 


More information about the Twisted-Python mailing list