Patch #1583 by Adam Olsen.

This adds signal.set_wakeup_fd(fd) which sets a file descriptor to
which a zero byte will be written whenever a C exception handler runs.

I added a simple C API as well, PySignal_SetWakeupFd(fd).
This commit is contained in:
Guido van Rossum 2007-12-19 19:41:06 +00:00
parent 80016c9555
commit 02de8979cc
5 changed files with 127 additions and 2 deletions

View file

@ -110,6 +110,20 @@ The :mod:`signal` module defines the following functions:
:manpage:`signal(2)`.)
.. function:: set_wakeup_fd(fd)
Set the wakeup fd to *fd*. When a signal is received, a ``'\0'`` byte is
written to the fd. This can be used by a library to wakeup a poll or select
call, allowing the signal to be fully processed.
The old wakeup fd is returned. *fd* must be non-blocking. It is up to the
library to remove any bytes before calling poll or select again.
When threads are enabled, this function can only be called from the main thread;
attempting to call it from other threads will cause a :exc:`ValueError`
exception to be raised.
.. function:: signal(signalnum, handler)
Set the handler for signal *signalnum* to the function *handler*. *handler* can