lib/waiter: handle -EINTR
authorJeremy Kerr <jk@ozlabs.org>
Mon, 19 Aug 2013 03:58:23 +0000 (11:58 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 19 Aug 2013 05:27:59 +0000 (13:27 +0800)
Now that we're handing non-fatal signals (i.e., SIGCHLD in the process
lib), we need to gracefully handle -EINTR from poll().

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/waiter/waiter.c
ui/ncurses/nc-cui.c
ui/twin/main-generic.c

index e201ad1fbdab2b209cf720d58313f2259d823b97..d684348f4fc9566be5bc6ab9023793b169e5580f 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdbool.h>
 #include <string.h>
 #include <assert.h>
+#include <errno.h>
 #include <sys/time.h>
 
 #include <talloc/talloc.h>
@@ -222,11 +223,13 @@ int waiter_poll(struct waitset *set)
                timeout_ms = -1;
        }
 
-
        rc = poll(set->pollfds, set->n_io_waiters, timeout_ms);
 
-       if (rc < 0)
+       if (rc < 0) {
+               if (errno == EINTR)
+                       rc = 0;
                goto out;
+       }
 
        for (i = 0; i < set->n_io_waiters; i++) {
                struct waiter *waiter = set->io_waiters[i];
index 4baaec17d52ca4c9e242b45669c7d5b01bdce776..71fec5e7d18345a3fc93b815d014400a29c47b86 100644 (file)
@@ -594,7 +594,7 @@ int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item)
        while (1) {
                int result = waiter_poll(cui->waitset);
 
-               if (result < 0 && errno != EINTR) {
+               if (result < 0) {
                        pb_log("%s: poll: %s\n", __func__, strerror(errno));
                        break;
                }
index fcda70970bdce1e5b8e4ba0f54f06a65e5790a7f..99520d0adde32b040884ab5511c97e8b117eb828 100644 (file)
@@ -204,7 +204,7 @@ static int run(struct pbt_client *client)
        while (1) {
                int result = waiter_poll(client->waitset);
 
-               if (result < 0 && errno != EINTR) {
+               if (result < 0) {
                        pb_log("%s: poll: %s\n", __func__, strerror(errno));
                        break;
                }