From e6d7e4fffbf486705bd055e715c4b732f5e1bcb1 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 15 Mar 2023 10:18:37 +0900 Subject: [PATCH] sexp_poll_port needs a timeout --- vm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vm.c b/vm.c index 8924f223..bf51af22 100644 --- a/vm.c +++ b/vm.c @@ -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