summaryrefslogtreecommitdiff
path: root/src/nsterm.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/nsterm.m')
-rw-r--r--src/nsterm.m25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index f094b145fe3..faf9324402b 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4739,12 +4739,15 @@ ns_select_1 (int nfds, fd_set *readfds, fd_set *writefds,
check_native_fs ();
#endif
- if (hold_event_q.nr > 0 && !run_loop_only)
+ /* If there are input events pending, store them so that Emacs can
+ recognize C-g. (And we must make sure [NSApp run] is called in
+ this function, so that C-g has a chance to land in
+ hold_event_q.) */
+ if (hold_event_q.nr > 0)
{
- /* We already have events pending. */
- raise (SIGIO);
- errno = EINTR;
- return -1;
+ for (int i = 0; i < hold_event_q.nr; ++i)
+ kbd_buffer_store_event_hold (&hold_event_q.q[i], NULL);
+ hold_event_q.nr = 0;
}
eassert (nfds <= FD_SETSIZE);
@@ -4754,11 +4757,15 @@ ns_select_1 (int nfds, fd_set *readfds, fd_set *writefds,
if (writefds && FD_ISSET(k, writefds)) ++nr;
}
- if (NSApp == nil
- || ![NSThread isMainThread]
+ /* 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]
|| (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0))
- return thread_select (pselect, nfds, readfds, writefds,
- exceptfds, timeout, sigmask);
+ thread_select (pselect, nfds, readfds, writefds,
+ exceptfds, timeout, sigmask);
else
{
struct timespec t = {0, 0};