summaryrefslogtreecommitdiffstats
path: root/Modules/signalmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-08-27 10:59:44 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-08-27 10:59:44 (GMT)
commit3822760f2d6ce4ab61daab2ab5ebc83bea839e92 (patch)
tree849139257c073fd7bf91252c94af2ea165b2fc24 /Modules/signalmodule.c
parent86cc17e69ebc002318d62501e914dc9bb394e503 (diff)
downloadcpython-3822760f2d6ce4ab61daab2ab5ebc83bea839e92.zip
cpython-3822760f2d6ce4ab61daab2ab5ebc83bea839e92.tar.gz
cpython-3822760f2d6ce4ab61daab2ab5ebc83bea839e92.tar.bz2
Issue #22042: signal.set_wakeup_fd(fd) now raises an exception if the file
descriptor is in blocking mode.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r--Modules/signalmodule.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 61b3330..38c5d21 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -561,9 +561,15 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args)
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
+
+ /* on Windows, a file cannot be set to non-blocking mode */
}
- else
+ else {
is_socket = 1;
+
+ /* Windows does not provide a function to test if a socket
+ is in non-blocking mode */
+ }
}
old_fd = wakeup.fd;
@@ -576,6 +582,8 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args)
return PyLong_FromLong(-1);
#else
if (fd != -1) {
+ int blocking;
+
if (!_PyVerify_fd(fd)) {
PyErr_SetString(PyExc_ValueError, "invalid fd");
return NULL;
@@ -585,6 +593,16 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args)
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
+
+ blocking = _Py_get_blocking(fd);
+ if (blocking < 0)
+ return NULL;
+ if (blocking) {
+ PyErr_Format(PyExc_ValueError,
+ "the fd %i must be in non-blocking mode",
+ fd);
+ return NULL;
+ }
}
old_fd = wakeup_fd;