From e8396d70bad9860d59c2e59028b651fe08d5db30 Mon Sep 17 00:00:00 2001 From: Felicity Tarnell Date: Fri, 7 Mar 2014 22:03:47 +0000 Subject: [PATCH] Always timeout the poll. Otherwise, events like the laststatus update and (more importantly) lastsave don't get run unless there's a running entry. --- tts.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tts.c b/tts.c index 4f35001..66a4b41 100644 --- a/tts.c +++ b/tts.c @@ -467,8 +467,7 @@ struct kevent64_s evs[2], rev; timeout.tv_sec = 0; timeout.tv_nsec = 500000000; - if ((nev = kevent64(kq, NULL, 0, &rev, 1, 0, - running ? &timeout : NULL)) == -1) { + if ((nev = kevent64(kq, NULL, 0, &rev, 1, 0, &timeout)) == -1) { if (doexit) break; if (errno == EINTR) @@ -477,9 +476,6 @@ struct kevent64_s evs[2], rev; return 1; } - if (nev == 0) - continue; - if (rev.filter == EVFILT_MACHPORT) { power_handle(&rev); continue; @@ -492,20 +488,12 @@ struct kevent64_s evs[2], rev; timeout.tv_sec = 0; timeout.tv_usec = 500000; - /* - * If there's a running entry, wake up in 0.5 seconds time to update - * the display. Otherwise, we can sleep forever. - */ - if (select(STDIN_FILENO + 1, &in_set, NULL, NULL, - running ? &timeout : NULL) == -1) { + if (select(STDIN_FILENO + 1, &in_set, NULL, NULL, &timeout) == -1) { if (doexit) break; if (errno == EINTR) continue; } - - if (!FD_ISSET(STDIN_FILENO, &in_set)) - continue; #endif while (GETCH(&c) != ERR) { @@ -529,8 +517,10 @@ struct kevent64_s evs[2], rev; if (doexit) break; + if (time(NULL) - laststatus >= 2) drawstatus(WIDE("")); + if (time(NULL) - lastsave > 60) save(); }