Always timeout the poll.

Otherwise, events like the laststatus update and (more importantly) lastsave
don't get run unless there's a running entry.
This commit is contained in:
Felicity Tarnell 2014-03-07 22:03:47 +00:00
parent 0c3b7443d5
commit e8396d70ba

18
tts.c
View file

@ -467,8 +467,7 @@ struct kevent64_s evs[2], rev;
timeout.tv_sec = 0; timeout.tv_sec = 0;
timeout.tv_nsec = 500000000; timeout.tv_nsec = 500000000;
if ((nev = kevent64(kq, NULL, 0, &rev, 1, 0, if ((nev = kevent64(kq, NULL, 0, &rev, 1, 0, &timeout)) == -1) {
running ? &timeout : NULL)) == -1) {
if (doexit) if (doexit)
break; break;
if (errno == EINTR) if (errno == EINTR)
@ -477,9 +476,6 @@ struct kevent64_s evs[2], rev;
return 1; return 1;
} }
if (nev == 0)
continue;
if (rev.filter == EVFILT_MACHPORT) { if (rev.filter == EVFILT_MACHPORT) {
power_handle(&rev); power_handle(&rev);
continue; continue;
@ -492,20 +488,12 @@ struct kevent64_s evs[2], rev;
timeout.tv_sec = 0; timeout.tv_sec = 0;
timeout.tv_usec = 500000; timeout.tv_usec = 500000;
/* if (select(STDIN_FILENO + 1, &in_set, NULL, NULL, &timeout) == -1) {
* 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 (doexit) if (doexit)
break; break;
if (errno == EINTR) if (errno == EINTR)
continue; continue;
} }
if (!FD_ISSET(STDIN_FILENO, &in_set))
continue;
#endif #endif
while (GETCH(&c) != ERR) { while (GETCH(&c) != ERR) {
@ -529,8 +517,10 @@ struct kevent64_s evs[2], rev;
if (doexit) if (doexit)
break; break;
if (time(NULL) - laststatus >= 2) if (time(NULL) - laststatus >= 2)
drawstatus(WIDE("")); drawstatus(WIDE(""));
if (time(NULL) - lastsave > 60) if (time(NULL) - lastsave > 60)
save(); save();
} }