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)
This commit is contained in:
Yavor Doganov 2026-01-18 16:01:55 +02:00 committed by Eli Zaretskii
parent 31c07d873b
commit b44053536d

View file

@ -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);
}