select: fix waiting on anonymous pipes on MS-Windows
The existing select() implementation for MS-Windows returned
immediately with a zero value when it is called to wait for input
from an anonymous pipe (e.g., a pipe created by a call to 'pipe' or
'pipe2'), as discussed at:
This was noticed while running Guile's test suite on MS-Windows.
Guile uses 'select', among other places, in its implementation
of 'sleep' and 'usleep' primitives. It calls 'select'
with a file descriptor of a signal delivery pipe, which is written to
(by another thread) when Guile is interrupted by a signal. But due to
the above-mentioned problem, these two functions never sleep, and
instead return immediately.
* lib/select.c (rpl_select): Fall back to polling when select()
indicates there is nothing to check, while due to the timeout not
expiring, activity is indicated on one of the handles.
Also clear the TIMEOUT argument if the timer does expire.