/usr/lib/python3/dist-packages/twisted/internet
NameSizeModeActions
iocpreactor/-0755rm
test/-0755rm
__pycache__/-0755rm
abstract.py192950644editdlrm
address.py52440644editdlrm
asyncioreactor.py111310644editdlrm
base.py473920644editdlrm
cfreactor.py174990644editdlrm
default.py18930644editdlrm
defer.py856540644editdlrm
endpoints.py774400644editdlrm
epollreactor.py89410644editdlrm
error.py134820644editdlrm
fdesc.py32370644editdlrm
gireactor.py46200644editdlrm
glib2reactor.py11150644editdlrm
gtk2reactor.py36400644editdlrm
gtk3reactor.py15270644editdlrm
inotify.py143960644editdlrm
interfaces.py980480644editdlrm
kqreactor.py108180644editdlrm
main.py10060644editdlrm
pollreactor.py59740644editdlrm
posixbase.py276040644editdlrm
process.py385160644editdlrm
protocol.py273910644editdlrm
pyuisupport.py8430644editdlrm
reactor.py18160644editdlrm
selectreactor.py61020644editdlrm
serialport.py22720644editdlrm
ssl.py86430644editdlrm
stdio.py10000644editdlrm
task.py336080644editdlrm
tcp.py549800644editdlrm
testing.py292320644editdlrm
threads.py38120644editdlrm
tksupport.py19710644editdlrm
udp.py186190644editdlrm
unix.py225080644editdlrm
utils.py86820644editdlrm
win32eventreactor.py152660644editdlrm
wxreactor.py53150644editdlrm
wxsupport.py13050644editdlrm
_baseprocess.py20030644editdlrm
_dumbwin32proc.py127760644editdlrm
_glibbase.py127060644editdlrm
_idna.py14220644editdlrm
_newtls.py91570644editdlrm
_pollingfile.py87910644editdlrm
_posixserialport.py20810644editdlrm
_posixstdio.py49960644editdlrm
_producer_helpers.py39090644editdlrm
_resolver.py84650644editdlrm
_signals.py26700644editdlrm
_sslverify.py727960644editdlrm
_threadedselect.py115820644editdlrm
_win32serialport.py49140644editdlrm
_win32stdio.py31400644editdlrm
__init__.py5210644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/internet/_signals.py (2670B)
# -*- test-case-name: twisted.internet.test.test_sigchld -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ This module is used to integrate child process termination into a reactor event loop. This is a challenging feature to provide because most platforms indicate process termination via SIGCHLD and do not provide a way to wait for that signal and arbitrary I/O events at the same time. The naive implementation involves installing a Python SIGCHLD handler; unfortunately this leads to other syscalls being interrupted (whenever SIGCHLD is received) and failing with EINTR (which almost no one is prepared to handle). This interruption can be disabled via siginterrupt(2) (or one of the equivalent mechanisms); however, if the SIGCHLD is delivered by the platform to a non-main thread (not a common occurrence, but difficult to prove impossible), the main thread (waiting on select() or another event notification API) may not wake up leading to an arbitrary delay before the child termination is noticed. The basic solution to all these issues involves enabling SA_RESTART (ie, disabling system call interruption) and registering a C signal handler which writes a byte to a pipe. The other end of the pipe is registered with the event loop, allowing it to wake up shortly after SIGCHLD is received. See L{twisted.internet.posixbase._SIGCHLDWaker} for the implementation of the event loop side of this solution. The use of a pipe this way is known as the U{self-pipe trick}. From Python version 2.6, C{signal.siginterrupt} and C{signal.set_wakeup_fd} provide the necessary C signal handler which writes to the pipe to be registered with C{SA_RESTART}. """ import signal def installHandler(fd): """ Install a signal handler which will write a byte to C{fd} when I{SIGCHLD} is received. This is implemented by installing a SIGCHLD handler that does nothing, setting the I{SIGCHLD} handler as not allowed to interrupt system calls, and using L{signal.set_wakeup_fd} to do the actual writing. @param fd: The file descriptor to which to write when I{SIGCHLD} is received. @type fd: C{int} """ if fd == -1: signal.signal(signal.SIGCHLD, signal.SIG_DFL) else: def noopSignalHandler(*args): pass signal.signal(signal.SIGCHLD, noopSignalHandler) signal.siginterrupt(signal.SIGCHLD, False) return signal.set_wakeup_fd(fd) def isDefaultHandler(): """ Determine whether the I{SIGCHLD} handler is the default or not. """ return signal.getsignal(signal.SIGCHLD) == signal.SIG_DFL