summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-12-19 19:41:06 (GMT)
committerGuido van Rossum <guido@python.org>2007-12-19 19:41:06 (GMT)
commit02de8979ccc09d1ef5162f64dbc9e546dae2da4e (patch)
treec7dcc55af17aa2cfe72b60f48353abbb2033e774 /Doc
parent80016c95554677cd172610501446b096edfb267c (diff)
downloadcpython-02de8979ccc09d1ef5162f64dbc9e546dae2da4e.zip
cpython-02de8979ccc09d1ef5162f64dbc9e546dae2da4e.tar.gz
cpython-02de8979ccc09d1ef5162f64dbc9e546dae2da4e.tar.bz2
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).
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/exceptions.rst10
-rw-r--r--Doc/library/signal.rst14
2 files changed, 24 insertions, 0 deletions
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index 68344f9..9424bf1 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -375,6 +375,16 @@ is a separate error indicator for each thread.
.. % thread.interrupt_main() (used from IDLE), so it's still needed.
+.. cfunction:: int PySignal_SetWakeupFd(int fd)
+
+ This utility function specifies a file descriptor to which a ``'\0'`` byte will
+ be written whenever a signal is received. It returns the previous such file
+ descriptor. The value ``-1`` disables the feature; this is the initial state.
+ This is equivalent to :func:`signal.set_wakeup_fd` in Python, but without any
+ error checking. *fd* should be a valid file descriptor. The function should
+ only be called from the main thread.
+
+
.. cfunction:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict)
This utility function creates and returns a new exception object. The *name*
diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst
index 54cce53..afb3166 100644
--- a/Doc/library/signal.rst
+++ b/Doc/library/signal.rst
@@ -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