From b44053536db891d328620e103aba5a15687eda42 Mon Sep 17 00:00:00 2001 From: Yavor Doganov Date: Sun, 18 Jan 2026 16:01:55 +0200 Subject: [PATCH] NS: Fix UI freezes and Lisp threads on GNUstep * src/nsterm.m (ns_select_1): Return thread_select if current thread is not the main thread or timeout is zero; otherwise call 'thread_select' with a minimal timeout to allow other Lisp threads to run. (Bug#80110, Bug#80112) --- src/nsterm.m | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 07f397b1c5d..ca06195a798 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5066,18 +5066,14 @@ ns_select_1 (int nfds, fd_set *readfds, fd_set *writefds, if (writefds && FD_ISSET(k, writefds)) ++nr; } - /* emacs -nw doesn't have an NSApp, so we're done. */ - if (NSApp == nil) - return thread_select (pselect, nfds, readfds, writefds, exceptfds, - timeout, sigmask); - - if (![NSThread isMainThread] + if (NSApp == nil + || ![NSThread isMainThread] || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0)) - thread_select (pselect, nfds, readfds, writefds, - exceptfds, timeout, sigmask); + return thread_select (pselect, nfds, readfds, writefds, + exceptfds, timeout, sigmask); else { - struct timespec t = {0, 0}; + struct timespec t = {0, 1}; thread_select (pselect, 0, NULL, NULL, NULL, &t, sigmask); }