module/clock: handle poll() failures

This commit is contained in:
Daniel Eklöf 2021-12-17 11:28:14 +01:00
parent cdd0b5b4f0
commit 8a11a3fbe5
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -2,6 +2,7 @@
#include <string.h>
#include <time.h>
#include <assert.h>
#include <errno.h>
#include <poll.h>
#include <sys/time.h>
@ -74,6 +75,8 @@ run(struct module *mod)
const struct bar *bar = mod->bar;
bar->refresh(bar);
int ret = 1;
while (true) {
struct timespec _now;
clock_gettime(CLOCK_REALTIME, &_now);
@ -119,15 +122,23 @@ run(struct module *mod)
now.tv_sec, now.tv_usec, timeout_ms);
struct pollfd fds[] = {{.fd = mod->abort_fd, .events = POLLIN}};
poll(fds, 1, timeout_ms);
if (poll(fds, 1, timeout_ms) < 0) {
if (errno == EINTR)
continue;
if (fds[0].revents & POLLIN)
LOG_ERRNO("failed to poll");
break;
}
if (fds[0].revents & POLLIN) {
ret = 0;
break;
}
bar->refresh(bar);
}
return 0;
return ret;
}
static struct module *