bpo-33332: Add signal.valid_signals() (GH-6581)
This commit is contained in:
parent
491bbedc20
commit
9d3627e311
|
@ -216,6 +216,15 @@ The :mod:`signal` module defines the following functions:
|
||||||
.. versionadded:: 3.8
|
.. versionadded:: 3.8
|
||||||
|
|
||||||
|
|
||||||
|
.. function:: valid_signals()
|
||||||
|
|
||||||
|
Return the set of valid signal numbers on this platform. This can be
|
||||||
|
less than ``range(1, NSIG)`` if some signals are reserved by the system
|
||||||
|
for internal use.
|
||||||
|
|
||||||
|
.. versionadded:: 3.8
|
||||||
|
|
||||||
|
|
||||||
.. function:: pause()
|
.. function:: pause()
|
||||||
|
|
||||||
Cause the process to sleep until a signal is received; the appropriate handler
|
Cause the process to sleep until a signal is received; the appropriate handler
|
||||||
|
@ -268,8 +277,8 @@ The :mod:`signal` module defines the following functions:
|
||||||
argument.
|
argument.
|
||||||
|
|
||||||
*mask* is a set of signal numbers (e.g. {:const:`signal.SIGINT`,
|
*mask* is a set of signal numbers (e.g. {:const:`signal.SIGINT`,
|
||||||
:const:`signal.SIGTERM`}). Use ``range(1, signal.NSIG)`` for a full mask
|
:const:`signal.SIGTERM`}). Use :func:`~signal.valid_signals` for a full
|
||||||
including all signals.
|
mask including all signals.
|
||||||
|
|
||||||
For example, ``signal.pthread_sigmask(signal.SIG_BLOCK, [])`` reads the
|
For example, ``signal.pthread_sigmask(signal.SIG_BLOCK, [])`` reads the
|
||||||
signal mask of the calling thread.
|
signal mask of the calling thread.
|
||||||
|
|
|
@ -167,8 +167,8 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
|
||||||
if not isinstance(sig, int):
|
if not isinstance(sig, int):
|
||||||
raise TypeError(f'sig must be an int, not {sig!r}')
|
raise TypeError(f'sig must be an int, not {sig!r}')
|
||||||
|
|
||||||
if not (1 <= sig < signal.NSIG):
|
if sig not in signal.valid_signals():
|
||||||
raise ValueError(f'sig {sig} out of range(1, {signal.NSIG})')
|
raise ValueError(f'invalid signal number {sig}')
|
||||||
|
|
||||||
def _make_read_pipe_transport(self, pipe, protocol, waiter=None,
|
def _make_read_pipe_transport(self, pipe, protocol, waiter=None,
|
||||||
extra=None):
|
extra=None):
|
||||||
|
|
|
@ -136,7 +136,7 @@ class _ResourceSharer(object):
|
||||||
|
|
||||||
def _serve(self):
|
def _serve(self):
|
||||||
if hasattr(signal, 'pthread_sigmask'):
|
if hasattr(signal, 'pthread_sigmask'):
|
||||||
signal.pthread_sigmask(signal.SIG_BLOCK, range(1, signal.NSIG))
|
signal.pthread_sigmask(signal.SIG_BLOCK, signal.valid_signals())
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
with self._listener.accept() as conn:
|
with self._listener.accept() as conn:
|
||||||
|
|
|
@ -65,8 +65,7 @@ if 'pthread_sigmask' in _globals:
|
||||||
if 'sigpending' in _globals:
|
if 'sigpending' in _globals:
|
||||||
@_wraps(_signal.sigpending)
|
@_wraps(_signal.sigpending)
|
||||||
def sigpending():
|
def sigpending():
|
||||||
sigs = _signal.sigpending()
|
return {_int_to_enum(x, Signals) for x in _signal.sigpending()}
|
||||||
return set(_int_to_enum(x, Signals) for x in sigs)
|
|
||||||
|
|
||||||
|
|
||||||
if 'sigwait' in _globals:
|
if 'sigwait' in _globals:
|
||||||
|
@ -76,4 +75,11 @@ if 'sigwait' in _globals:
|
||||||
return _int_to_enum(retsig, Signals)
|
return _int_to_enum(retsig, Signals)
|
||||||
sigwait.__doc__ = _signal.sigwait
|
sigwait.__doc__ = _signal.sigwait
|
||||||
|
|
||||||
|
|
||||||
|
if 'valid_signals' in _globals:
|
||||||
|
@_wraps(_signal.valid_signals)
|
||||||
|
def valid_signals():
|
||||||
|
return {_int_to_enum(x, Signals) for x in _signal.valid_signals()}
|
||||||
|
|
||||||
|
|
||||||
del _globals, _wraps
|
del _globals, _wraps
|
||||||
|
|
|
@ -2810,7 +2810,7 @@ class SaveSignals:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
import signal
|
import signal
|
||||||
self.signal = signal
|
self.signal = signal
|
||||||
self.signals = list(range(1, signal.NSIG))
|
self.signals = signal.valid_signals()
|
||||||
# SIGKILL and SIGSTOP signals cannot be ignored nor caught
|
# SIGKILL and SIGSTOP signals cannot be ignored nor caught
|
||||||
for signame in ('SIGKILL', 'SIGSTOP'):
|
for signame in ('SIGKILL', 'SIGSTOP'):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -69,6 +69,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_add_signal_handler_setup_error(self, m_signal):
|
def test_add_signal_handler_setup_error(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
m_signal.set_wakeup_fd.side_effect = ValueError
|
m_signal.set_wakeup_fd.side_effect = ValueError
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
|
@ -96,6 +97,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_add_signal_handler(self, m_signal):
|
def test_add_signal_handler(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
|
|
||||||
cb = lambda: True
|
cb = lambda: True
|
||||||
self.loop.add_signal_handler(signal.SIGHUP, cb)
|
self.loop.add_signal_handler(signal.SIGHUP, cb)
|
||||||
|
@ -106,6 +108,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_add_signal_handler_install_error(self, m_signal):
|
def test_add_signal_handler_install_error(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
|
|
||||||
def set_wakeup_fd(fd):
|
def set_wakeup_fd(fd):
|
||||||
if fd == -1:
|
if fd == -1:
|
||||||
|
@ -125,6 +128,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.base_events.logger')
|
@mock.patch('asyncio.base_events.logger')
|
||||||
def test_add_signal_handler_install_error2(self, m_logging, m_signal):
|
def test_add_signal_handler_install_error2(self, m_logging, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
|
|
||||||
class Err(OSError):
|
class Err(OSError):
|
||||||
errno = errno.EINVAL
|
errno = errno.EINVAL
|
||||||
|
@ -145,6 +149,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
errno = errno.EINVAL
|
errno = errno.EINVAL
|
||||||
m_signal.signal.side_effect = Err
|
m_signal.signal.side_effect = Err
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
RuntimeError,
|
RuntimeError,
|
||||||
|
@ -156,6 +161,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_remove_signal_handler(self, m_signal):
|
def test_remove_signal_handler(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
|
|
||||||
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
||||||
|
|
||||||
|
@ -170,6 +176,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
def test_remove_signal_handler_2(self, m_signal):
|
def test_remove_signal_handler_2(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
m_signal.SIGINT = signal.SIGINT
|
m_signal.SIGINT = signal.SIGINT
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
|
|
||||||
self.loop.add_signal_handler(signal.SIGINT, lambda: True)
|
self.loop.add_signal_handler(signal.SIGINT, lambda: True)
|
||||||
self.loop._signal_handlers[signal.SIGHUP] = object()
|
self.loop._signal_handlers[signal.SIGHUP] = object()
|
||||||
|
@ -187,6 +194,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.base_events.logger')
|
@mock.patch('asyncio.base_events.logger')
|
||||||
def test_remove_signal_handler_cleanup_error(self, m_logging, m_signal):
|
def test_remove_signal_handler_cleanup_error(self, m_logging, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
||||||
|
|
||||||
m_signal.set_wakeup_fd.side_effect = ValueError
|
m_signal.set_wakeup_fd.side_effect = ValueError
|
||||||
|
@ -197,6 +205,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_remove_signal_handler_error(self, m_signal):
|
def test_remove_signal_handler_error(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
||||||
|
|
||||||
m_signal.signal.side_effect = OSError
|
m_signal.signal.side_effect = OSError
|
||||||
|
@ -207,6 +216,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_remove_signal_handler_error2(self, m_signal):
|
def test_remove_signal_handler_error2(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
||||||
|
|
||||||
class Err(OSError):
|
class Err(OSError):
|
||||||
|
@ -219,6 +229,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_close(self, m_signal):
|
def test_close(self, m_signal):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
|
|
||||||
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
||||||
self.loop.add_signal_handler(signal.SIGCHLD, lambda: True)
|
self.loop.add_signal_handler(signal.SIGCHLD, lambda: True)
|
||||||
|
@ -236,6 +247,7 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
|
||||||
@mock.patch('asyncio.unix_events.signal')
|
@mock.patch('asyncio.unix_events.signal')
|
||||||
def test_close_on_finalizing(self, m_signal, m_sys):
|
def test_close_on_finalizing(self, m_signal, m_sys):
|
||||||
m_signal.NSIG = signal.NSIG
|
m_signal.NSIG = signal.NSIG
|
||||||
|
m_signal.valid_signals = signal.valid_signals
|
||||||
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
self.loop.add_signal_handler(signal.SIGHUP, lambda: True)
|
||||||
|
|
||||||
self.assertEqual(len(self.loop._signal_handlers), 1)
|
self.assertEqual(len(self.loop._signal_handlers), 1)
|
||||||
|
|
|
@ -67,9 +67,28 @@ class PosixTests(unittest.TestCase):
|
||||||
script = os.path.join(dirname, 'signalinterproctester.py')
|
script = os.path.join(dirname, 'signalinterproctester.py')
|
||||||
assert_python_ok(script)
|
assert_python_ok(script)
|
||||||
|
|
||||||
|
def test_valid_signals(self):
|
||||||
|
s = signal.valid_signals()
|
||||||
|
self.assertIsInstance(s, set)
|
||||||
|
self.assertIn(signal.Signals.SIGINT, s)
|
||||||
|
self.assertIn(signal.Signals.SIGALRM, s)
|
||||||
|
self.assertNotIn(0, s)
|
||||||
|
self.assertNotIn(signal.NSIG, s)
|
||||||
|
self.assertLess(len(s), signal.NSIG)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform == "win32", "Windows specific")
|
@unittest.skipUnless(sys.platform == "win32", "Windows specific")
|
||||||
class WindowsSignalTests(unittest.TestCase):
|
class WindowsSignalTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_valid_signals(self):
|
||||||
|
s = signal.valid_signals()
|
||||||
|
self.assertIsInstance(s, set)
|
||||||
|
self.assertGreaterEqual(len(s), 6)
|
||||||
|
self.assertIn(signal.Signals.SIGINT, s)
|
||||||
|
self.assertNotIn(0, s)
|
||||||
|
self.assertNotIn(signal.NSIG, s)
|
||||||
|
self.assertLess(len(s), signal.NSIG)
|
||||||
|
|
||||||
def test_issue9324(self):
|
def test_issue9324(self):
|
||||||
# Updated for issue #10003, adding SIGBREAK
|
# Updated for issue #10003, adding SIGBREAK
|
||||||
handler = lambda x, y: None
|
handler = lambda x, y: None
|
||||||
|
@ -922,6 +941,17 @@ class PendingSignalsTests(unittest.TestCase):
|
||||||
self.assertRaises(TypeError, signal.pthread_sigmask, 1)
|
self.assertRaises(TypeError, signal.pthread_sigmask, 1)
|
||||||
self.assertRaises(TypeError, signal.pthread_sigmask, 1, 2, 3)
|
self.assertRaises(TypeError, signal.pthread_sigmask, 1, 2, 3)
|
||||||
self.assertRaises(OSError, signal.pthread_sigmask, 1700, [])
|
self.assertRaises(OSError, signal.pthread_sigmask, 1700, [])
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
signal.pthread_sigmask(signal.SIG_BLOCK, [signal.NSIG])
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(signal, 'pthread_sigmask'),
|
||||||
|
'need signal.pthread_sigmask()')
|
||||||
|
def test_pthread_sigmask_valid_signals(self):
|
||||||
|
s = signal.pthread_sigmask(signal.SIG_BLOCK, signal.valid_signals())
|
||||||
|
self.addCleanup(signal.pthread_sigmask, signal.SIG_SETMASK, s)
|
||||||
|
# Get current blocked set
|
||||||
|
s = signal.pthread_sigmask(signal.SIG_UNBLOCK, signal.valid_signals())
|
||||||
|
self.assertLessEqual(s, signal.valid_signals())
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(signal, 'pthread_sigmask'),
|
@unittest.skipUnless(hasattr(signal, 'pthread_sigmask'),
|
||||||
'need signal.pthread_sigmask()')
|
'need signal.pthread_sigmask()')
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Add ``signal.valid_signals()`` to expose the POSIX sigfillset()
|
||||||
|
functionality.
|
|
@ -341,6 +341,31 @@ PyDoc_STRVAR(signal_sigwait__doc__,
|
||||||
|
|
||||||
#endif /* defined(HAVE_SIGWAIT) */
|
#endif /* defined(HAVE_SIGWAIT) */
|
||||||
|
|
||||||
|
#if (defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS))
|
||||||
|
|
||||||
|
PyDoc_STRVAR(signal_valid_signals__doc__,
|
||||||
|
"valid_signals($module, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return a set of valid signal numbers on this platform.\n"
|
||||||
|
"\n"
|
||||||
|
"The signal numbers returned by this function can be safely passed to\n"
|
||||||
|
"functions like `pthread_sigmask`.");
|
||||||
|
|
||||||
|
#define SIGNAL_VALID_SIGNALS_METHODDEF \
|
||||||
|
{"valid_signals", (PyCFunction)signal_valid_signals, METH_NOARGS, signal_valid_signals__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
signal_valid_signals_impl(PyObject *module);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
signal_valid_signals(PyObject *module, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return signal_valid_signals_impl(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)) */
|
||||||
|
|
||||||
#if defined(HAVE_SIGWAITINFO)
|
#if defined(HAVE_SIGWAITINFO)
|
||||||
|
|
||||||
PyDoc_STRVAR(signal_sigwaitinfo__doc__,
|
PyDoc_STRVAR(signal_sigwaitinfo__doc__,
|
||||||
|
@ -459,6 +484,10 @@ exit:
|
||||||
#define SIGNAL_SIGWAIT_METHODDEF
|
#define SIGNAL_SIGWAIT_METHODDEF
|
||||||
#endif /* !defined(SIGNAL_SIGWAIT_METHODDEF) */
|
#endif /* !defined(SIGNAL_SIGWAIT_METHODDEF) */
|
||||||
|
|
||||||
|
#ifndef SIGNAL_VALID_SIGNALS_METHODDEF
|
||||||
|
#define SIGNAL_VALID_SIGNALS_METHODDEF
|
||||||
|
#endif /* !defined(SIGNAL_VALID_SIGNALS_METHODDEF) */
|
||||||
|
|
||||||
#ifndef SIGNAL_SIGWAITINFO_METHODDEF
|
#ifndef SIGNAL_SIGWAITINFO_METHODDEF
|
||||||
#define SIGNAL_SIGWAITINFO_METHODDEF
|
#define SIGNAL_SIGWAITINFO_METHODDEF
|
||||||
#endif /* !defined(SIGNAL_SIGWAITINFO_METHODDEF) */
|
#endif /* !defined(SIGNAL_SIGWAITINFO_METHODDEF) */
|
||||||
|
@ -470,4 +499,4 @@ exit:
|
||||||
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
|
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
|
||||||
#define SIGNAL_PTHREAD_KILL_METHODDEF
|
#define SIGNAL_PTHREAD_KILL_METHODDEF
|
||||||
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
|
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
|
||||||
/*[clinic end generated code: output=7b41486acf93aa8e input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=f35d79e0cfee3f1b input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -841,11 +841,21 @@ iterable_to_sigset(PyObject *iterable, sigset_t *mask)
|
||||||
if (signum == -1 && PyErr_Occurred())
|
if (signum == -1 && PyErr_Occurred())
|
||||||
goto error;
|
goto error;
|
||||||
if (0 < signum && signum < NSIG) {
|
if (0 < signum && signum < NSIG) {
|
||||||
/* bpo-33329: ignore sigaddset() return value as it can fail
|
if (sigaddset(mask, (int)signum)) {
|
||||||
* for some reserved signals, but we want the `range(1, NSIG)`
|
if (errno != EINVAL) {
|
||||||
* idiom to allow selecting all valid signals.
|
/* Probably impossible */
|
||||||
|
PyErr_SetFromErrno(PyExc_OSError);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
/* For backwards compatibility, allow idioms such as
|
||||||
|
* `range(1, NSIG)` but warn about invalid signal numbers
|
||||||
*/
|
*/
|
||||||
(void) sigaddset(mask, (int)signum);
|
const char *msg =
|
||||||
|
"invalid signal number %ld, please use valid_signals()";
|
||||||
|
if (PyErr_WarnFormat(PyExc_RuntimeWarning, 1, msg, signum)) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
|
@ -1001,6 +1011,47 @@ signal_sigwait(PyObject *module, PyObject *sigset)
|
||||||
#endif /* #ifdef HAVE_SIGWAIT */
|
#endif /* #ifdef HAVE_SIGWAIT */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
signal.valid_signals
|
||||||
|
|
||||||
|
Return a set of valid signal numbers on this platform.
|
||||||
|
|
||||||
|
The signal numbers returned by this function can be safely passed to
|
||||||
|
functions like `pthread_sigmask`.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
signal_valid_signals_impl(PyObject *module)
|
||||||
|
/*[clinic end generated code: output=1609cffbcfcf1314 input=86a3717ff25288f2]*/
|
||||||
|
{
|
||||||
|
#ifdef MS_WINDOWS
|
||||||
|
#ifdef SIGBREAK
|
||||||
|
PyObject *tup = Py_BuildValue("(iiiiiii)", SIGABRT, SIGBREAK, SIGFPE,
|
||||||
|
SIGILL, SIGINT, SIGSEGV, SIGTERM);
|
||||||
|
#else
|
||||||
|
PyObject *tup = Py_BuildValue("(iiiiii)", SIGABRT, SIGFPE, SIGILL,
|
||||||
|
SIGINT, SIGSEGV, SIGTERM);
|
||||||
|
#endif
|
||||||
|
if (tup == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject *set = PySet_New(tup);
|
||||||
|
Py_DECREF(tup);
|
||||||
|
return set;
|
||||||
|
#else
|
||||||
|
sigset_t mask;
|
||||||
|
if (sigemptyset(&mask) || sigfillset(&mask)) {
|
||||||
|
return PyErr_SetFromErrno(PyExc_OSError);
|
||||||
|
}
|
||||||
|
return sigset_to_set(mask);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS) */
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
|
#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
|
||||||
static int initialized;
|
static int initialized;
|
||||||
static PyStructSequence_Field struct_siginfo_fields[] = {
|
static PyStructSequence_Field struct_siginfo_fields[] = {
|
||||||
|
@ -1225,6 +1276,9 @@ static PyMethodDef signal_methods[] = {
|
||||||
SIGNAL_SIGWAIT_METHODDEF
|
SIGNAL_SIGWAIT_METHODDEF
|
||||||
SIGNAL_SIGWAITINFO_METHODDEF
|
SIGNAL_SIGWAITINFO_METHODDEF
|
||||||
SIGNAL_SIGTIMEDWAIT_METHODDEF
|
SIGNAL_SIGTIMEDWAIT_METHODDEF
|
||||||
|
#if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)
|
||||||
|
SIGNAL_VALID_SIGNALS_METHODDEF
|
||||||
|
#endif
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
|
# generated automatically by aclocal 1.15 -*- Autoconf -*-
|
||||||
|
|
||||||
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This file is free software; the Free Software Foundation
|
# This file is free software; the Free Software Foundation
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
@ -12,9 +12,9 @@
|
||||||
# PARTICULAR PURPOSE.
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||||
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||||
# serial 12 (pkg-config-0.29.2)
|
dnl serial 11 (pkg-config-0.29.1)
|
||||||
|
dnl
|
||||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||||
dnl
|
dnl
|
||||||
|
@ -55,7 +55,7 @@ dnl
|
||||||
dnl See the "Since" comment for each macro you use to see what version
|
dnl See the "Since" comment for each macro you use to see what version
|
||||||
dnl of the macros you require.
|
dnl of the macros you require.
|
||||||
m4_defun([PKG_PREREQ],
|
m4_defun([PKG_PREREQ],
|
||||||
[m4_define([PKG_MACROS_VERSION], [0.29.2])
|
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||||
])dnl PKG_PREREQ
|
])dnl PKG_PREREQ
|
||||||
|
@ -156,7 +156,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
|
||||||
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
|
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
|
||||||
|
|
||||||
pkg_failed=no
|
pkg_failed=no
|
||||||
AC_MSG_CHECKING([for $2])
|
AC_MSG_CHECKING([for $1])
|
||||||
|
|
||||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||||
|
|
|
@ -11259,7 +11259,7 @@ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
|
||||||
setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
|
setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
|
||||||
sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
|
sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
|
||||||
sched_rr_get_interval \
|
sched_rr_get_interval \
|
||||||
sigaction sigaltstack siginterrupt sigpending sigrelse \
|
sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \
|
||||||
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
|
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
|
||||||
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
||||||
truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
|
truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
|
||||||
|
|
|
@ -3474,7 +3474,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
|
||||||
setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
|
setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
|
||||||
sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
|
sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
|
||||||
sched_rr_get_interval \
|
sched_rr_get_interval \
|
||||||
sigaction sigaltstack siginterrupt sigpending sigrelse \
|
sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \
|
||||||
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
|
sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
|
||||||
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
||||||
truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
|
truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
|
||||||
|
|
|
@ -896,6 +896,9 @@
|
||||||
/* Define to 1 if you have the `sigaltstack' function. */
|
/* Define to 1 if you have the `sigaltstack' function. */
|
||||||
#undef HAVE_SIGALTSTACK
|
#undef HAVE_SIGALTSTACK
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sigfillset' function. */
|
||||||
|
#undef HAVE_SIGFILLSET
|
||||||
|
|
||||||
/* Define to 1 if `si_band' is a member of `siginfo_t'. */
|
/* Define to 1 if `si_band' is a member of `siginfo_t'. */
|
||||||
#undef HAVE_SIGINFO_T_SI_BAND
|
#undef HAVE_SIGINFO_T_SI_BAND
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue