Check for EINTR in poll$nt()

This is a bandaid that lets CTRL-C work in daemons until a better
solution for signals on Windows can be implemented.
This commit is contained in:
Justine Tunney 2021-01-28 15:49:15 -08:00
parent d8fffd2123
commit 971bc8147f
9 changed files with 58 additions and 12 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/bits.h"
#include "libc/calls/internal.h"
#include "libc/macros.h"
#include "libc/nt/struct/pollfd.h"
@ -37,6 +38,7 @@ textwindows int poll$nt(struct pollfd *fds, uint64_t nfds, uint64_t timeoutms) {
ntfds[i].events = fds[i].events & (POLLPRI | POLLIN | POLLOUT);
}
for (;;) {
if (cmpxchg(&__interrupted, true, false)) return eintr();
waitfor = MIN(1000, timeoutms); /* for ctrl+c */
if ((got = WSAPoll(ntfds, nfds, waitfor)) != -1) {
if (!got && (timeoutms -= waitfor)) continue;