Part of twisted.internet View Source
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 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 self-pipe
trick.
From Python version 2.6, signal.siginterrupt
and
signal.set_wakeup_fd
provide the necessary C signal handler
which writes to the pipe to be registered with SA_RESTART
.
Function | installHandler | Install a signal handler which will write a byte to fd when
SIGCHLD is received. |
Function | isDefaultHandler | Determine whether the SIGCHLD handler is the default or not. |
fd
when
SIGCHLD is received.
This is implemented by installing a SIGCHLD handler that does nothing,
setting the SIGCHLD handler as not allowed to interrupt system
calls, and using signal.set_wakeup_fd
to do the actual writing.
Parameters | fd | The file descriptor to which to write when SIGCHLD is received. (type: int ) |