sexp_poll_port needs a timeout

This commit is contained in:
Alex Shinn 2023-03-15 10:18:37 +09:00
parent 82dfe95468
commit e6d7e4fffb

5
vm.c
View file

@ -1055,6 +1055,7 @@ static void* sexp_thread_debug_event(sexp ctx) {
#if SEXP_USE_POLL_PORT
int sexp_poll_port(sexp ctx, sexp port, int inputp) {
fd_set fds;
struct timeval timeout;
int fd = sexp_port_fileno(port);
if (fd < 0) {
usleep(SEXP_POLL_SLEEP_TIME);
@ -1062,7 +1063,9 @@ int sexp_poll_port(sexp ctx, sexp port, int inputp) {
}
FD_ZERO(&fds);
FD_SET(fd, &fds);
return select(1, (inputp ? &fds : NULL), (inputp ? NULL : &fds), NULL, NULL);
timeout.tv_sec = 0;
timeout.tv_usec = 10000; /* 10millis */
return select(1, (inputp ? &fds : NULL), (inputp ? NULL : &fds), NULL, &timeout);
}
#endif