Commit 7f52415a authored by Oran Avraham's avatar Oran Avraham Committed by Victor Stinner

bpo-35310: Clear select() lists before returning upon EINTR (GH-10877)

select() calls are retried on EINTR (per PEP 475).  However, if a
timeout was provided and the deadline has passed after running the
signal handlers, rlist, wlist and xlist should be cleared since select(2)
left them unmodified.
parent 67a93b3a
Fix a bug in :func:`select.select` where, in some cases, the file descriptor
sequences were returned unmodified after a signal interruption, even though the
file descriptors might not be ready yet. :func:`select.select` will now always
return empty lists if a timeout has occurred. Patch by Oran Avraham.
......@@ -335,6 +335,10 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
if (tvp) {
timeout = deadline - _PyTime_GetMonotonicClock();
if (timeout < 0) {
/* bpo-35310: lists were unmodified -- clear them explicitly */
FD_ZERO(&ifdset);
FD_ZERO(&ofdset);
FD_ZERO(&efdset);
n = 0;
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment