[Python-checkins] r80687 - in python/branches/signalfd-issue8407: Doc/library/signal.rst Misc/NEWS Modules/signalmodule.c configure configure.in pyconfig.h.in

jean-paul.calderone python-checkins at python.org
Sat May 1 17:16:58 CEST 2010


Author: jean-paul.calderone
Date: Sat May  1 17:16:57 2010
New Revision: 80687

Log:
Document, add necessary build stuff, expose (but not yet test) SFD_*

Modified:
   python/branches/signalfd-issue8407/Doc/library/signal.rst
   python/branches/signalfd-issue8407/Misc/NEWS
   python/branches/signalfd-issue8407/Modules/signalmodule.c
   python/branches/signalfd-issue8407/configure
   python/branches/signalfd-issue8407/configure.in
   python/branches/signalfd-issue8407/pyconfig.h.in

Modified: python/branches/signalfd-issue8407/Doc/library/signal.rst
==============================================================================
--- python/branches/signalfd-issue8407/Doc/library/signal.rst	(original)
+++ python/branches/signalfd-issue8407/Doc/library/signal.rst	Sat May  1 17:16:57 2010
@@ -14,9 +14,6 @@
   underlying implementation), with the exception of the handler for
   :const:`SIGCHLD`, which follows the underlying implementation.
 
-* There is no way to "block" signals temporarily from critical sections (since
-  this is not supported by all Unix flavors).
-
 * Although Python signal handlers are called asynchronously as far as the Python
   user is concerned, they can only occur between the "atomic" instructions of the
   Python interpreter.  This means that signals arriving during long calculations
@@ -113,6 +110,35 @@
    in user and kernel space. SIGPROF is delivered upon expiration.
 
 
+.. data:: SIG_BLOCK
+
+   A possible value for the *how* parameter to :func:`sigprocmask`
+   indicating that signals are to be blocked.
+
+
+.. data:: SIG_UNBLOCK
+
+   A possible value for the *how* parameter to :func:`sigprocmask`
+   indicating that signals are to be unblocked.
+
+
+.. data:: SIG_SETMASK
+
+   A possible value for the *how* parameter to :func:`sigprocmask`
+   indicating that the signal mask is to be replaced.
+
+
+.. data:: SFD_CLOEXEC
+
+   A possible flag in the *flags* parameter to :func:`signalfd` which causes
+   the new file descriptor to be marked as close-on-exec.
+
+.. data:: SFD_NONBLOCK
+
+   A possible flag in the *flags* parameter to :func:`signalfd` which causes
+   the new file description to be set non-blocking.
+
+
 The :mod:`signal` module defines one exception:
 
 .. exception:: ItimerError
@@ -231,6 +257,46 @@
    attribute descriptions in the :mod:`inspect` module).
 
 
+.. function:: signalfd(fd, mask[, flags])
+
+   Create a new file descriptor on which to receive signals or modify the
+   mask of such a file descriptor previously created by this function.
+   Availability: Linux (See the manpage :manpage:`signalfd(2)` for further
+   information).
+
+   If *fd* is ``-1``, a new file descriptor will be created.  Otherwise,
+   *fd* must be a file descriptor previously returned by this function.
+
+   *mask* is a list of signal numbers which will trigger data on this file
+   descriptor.
+
+   *flags* is a bitvector which may include any :const:`signal.SFD_*` flag.
+
+   .. versionadded:: X.Y
+
+
+.. function:: sigprocmask(how, mask)
+
+   Set the signal mask for the process.  The old signal mask is returned.
+   Availability: Unix (See the Unix man page :manpage:`sigprocmask(2)`.)
+
+   If *how* is :const:`signal.SIG_BLOCK`, the signals in the mask are added
+   to the set of blocked signals.
+
+   If *how* is :const:`signal.SIG_UNBLOCK`, the signals in the mask are
+   removed from the set of blocked signals.
+
+   If *how* is :const:`signal.SIG_SETMASK`, the signals in the mask are set
+   as blocked and the signals not in the mask are set as unblocked.
+
+   *mask* is a list of signal numbers (eg :const:`signal.SIGUSR1`).
+
+   The behavior of this function in a multi-threaded program is unspecified.
+   See :func:`thread.sigmask` for multi-threaded uses. XXX
+
+  .. versionadded:: X.Y
+
+
 .. _signal-example:
 
 Example

Modified: python/branches/signalfd-issue8407/Misc/NEWS
==============================================================================
--- python/branches/signalfd-issue8407/Misc/NEWS	(original)
+++ python/branches/signalfd-issue8407/Misc/NEWS	Sat May  1 17:16:57 2010
@@ -1286,6 +1286,11 @@
 Library
 -------
 
+- Issue #8407: The signal module gains the ``signalfd()`` and
+  ``sigprocmask(2)`` functions providing access to the signalfd(2) and
+  sigprocmask(2) system calls respectively on Linux systems which implement
+  them.
+
 - Add count() and reverse() methods to collections.deque().
 
 - Fix variations of extending deques:  d.extend(d)  d.extendleft(d)  d+=d

Modified: python/branches/signalfd-issue8407/Modules/signalmodule.c
==============================================================================
--- python/branches/signalfd-issue8407/Modules/signalmodule.c	(original)
+++ python/branches/signalfd-issue8407/Modules/signalmodule.c	Sat May  1 17:16:57 2010
@@ -946,6 +946,18 @@
     Py_DECREF(x);
 #endif
 
+#ifdef SFD_CLOEXEC
+    x = PyLong_FromLong(SFD_CLOEXEC);
+    PyDict_SetItemString(d, "SFD_CLOEXEC", x);
+    Py_DECREF(x);
+#endif
+
+#ifdef SFD_NONBLOCK
+    x = PyLong_FromLong(SFD_NONBLOCK);
+    PyDict_SetItemString(d, "SFD_NONBLOCK", x);
+    Py_DECREF(x);
+#endif
+
 #ifdef CTRL_C_EVENT
     x = PyInt_FromLong(CTRL_C_EVENT);
     PyDict_SetItemString(d, "CTRL_C_EVENT", x);

Modified: python/branches/signalfd-issue8407/configure
==============================================================================
--- python/branches/signalfd-issue8407/configure	(original)
+++ python/branches/signalfd-issue8407/configure	Sat May  1 17:16:57 2010
@@ -18290,7 +18290,7 @@
  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
  setlocale setregid setreuid setresuid setresgid \
  setsid setpgid setpgrp setuid setvbuf snprintf \
- sigaction siginterrupt sigrelse strftime \
+ sigaction siginterrupt signalfd sigprocmask sigrelse strftime \
  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty
 do

Modified: python/branches/signalfd-issue8407/configure.in
==============================================================================
--- python/branches/signalfd-issue8407/configure.in	(original)
+++ python/branches/signalfd-issue8407/configure.in	Sat May  1 17:16:57 2010
@@ -2662,7 +2662,7 @@
  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
  setlocale setregid setreuid setresuid setresgid \
  setsid setpgid setpgrp setuid setvbuf snprintf \
- sigaction siginterrupt sigrelse strftime \
+ sigaction siginterrupt signalfd sigprocmask sigrelse strftime \
  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
 

Modified: python/branches/signalfd-issue8407/pyconfig.h.in
==============================================================================
--- python/branches/signalfd-issue8407/pyconfig.h.in	(original)
+++ python/branches/signalfd-issue8407/pyconfig.h.in	Sat May  1 17:16:57 2010
@@ -619,6 +619,12 @@
 /* Define to 1 if you have the <signal.h> header file. */
 #undef HAVE_SIGNAL_H
 
+/* Define to 1 if you have the `signalfd' function. */
+#undef HAVE_SIGNALFD
+
+/* Define to 1 if you have the `sigprocmask' function. */
+#undef HAVE_SIGPROCMASK
+
 /* Define to 1 if you have the `sigrelse' function. */
 #undef HAVE_SIGRELSE
 


More information about the Python-checkins mailing list