diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index bc43432be..0e89617e2 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -140,6 +140,8 @@ loop(ChildMonitor *self) { for (i = 0; i < self->count + EXTRA_FDS; i++) self->fds[i].revents = 0; for (i = EXTRA_FDS; i < EXTRA_FDS + self->count; i++) self->fds[i].events = self->children[i - EXTRA_FDS].needs_write ? POLLOUT | POLLIN : POLLIN; timeout = (int)(timers_timeout(self->timers) * 1000); + // Sub-millisecond interval will become 0, so round up to 1ms as this is the resolution of poll() + if (timeout == 0) timeout = 1; Py_BEGIN_ALLOW_THREADS; ret = poll(self->fds, self->count + EXTRA_FDS, timeout); Py_END_ALLOW_THREADS; @@ -166,6 +168,7 @@ loop(ChildMonitor *self) { for (i = 0; i < self->count; i++) { if (self->children[i].screen->change_tracker->dirty) { if (!timers_add_if_missing(self->timers, self->repaint_delay, self->children[i].update_screen, NULL)) PyErr_Print(); + // update_screen() is responsible for clearing the dirty indication } } } diff --git a/kitty/timers.c b/kitty/timers.c index 5e32d8f65..5149bf91a 100644 --- a/kitty/timers.c +++ b/kitty/timers.c @@ -162,6 +162,7 @@ remove_event(Timers *self, PyObject *callback) { double timers_timeout(Timers *self) { + if (self->count < 1) return -1; double ans = self->events[0].at - monotonic(); return MAX(0, ans); }