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.
(cherry picked from commit 7f52415a6d4841d77d3b7853e83b25a22e0048dc)
Co-authored-by: Oran Avraham <252748+oranav@users.noreply.github.com>
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 63266af..88679e8 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -279,6 +279,10 @@
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;
}