From 9a3719817ef06d3cc753ed0606b10d72e61bd7f2 Mon Sep 17 00:00:00 2001 From: Felicity Tarnell Date: Fri, 7 Mar 2014 21:58:10 +0000 Subject: [PATCH] Fix ^C handling. --- tts.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tts.c b/tts.c index 70e45f0..630e31a 100644 --- a/tts.c +++ b/tts.c @@ -470,6 +470,10 @@ struct kevent64_s evs[2], rev; if ((nev = kevent64(kq, NULL, 0, &rev, 1, 0, running ? &timeout : NULL)) == -1) { + if (doexit) + break; + if (errno == EINTR) + continue; perror("kevent"); return 1; } @@ -493,8 +497,13 @@ struct kevent64_s evs[2], rev; * If there's a running entry, wake up in 0.5 seconds time to update * the display. Otherwise, we can sleep forever. */ - select(STDIN_FILENO + 1, &in_set, NULL, NULL, - running ? &timeout : NULL); + if (select(STDIN_FILENO + 1, &in_set, NULL, NULL, + running ? &timeout : NULL) == -1) { + if (doexit) + break; + if (errno == EINTR) + continue; + } if (!FD_ISSET(STDIN_FILENO, &in_set)) continue;