module/battery: handle poll() failures

This commit is contained in:
Daniel Eklöf 2021-12-17 11:25:37 +01:00
parent 6612a9af9f
commit f922973450
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -428,7 +428,15 @@ run(struct module *mod)
{.fd = mod->abort_fd, .events = POLLIN},
{.fd = udev_monitor_get_fd(mon), .events = POLLIN},
};
poll(fds, 2, m->poll_interval > 0 ? m->poll_interval * 1000 : -1);
if (poll(fds, sizeof(fds) / sizeof(fds[0]),
m->poll_interval > 0 ? m->poll_interval * 1000 : -1) < 0)
{
if (errno == EINTR)
continue;
LOG_ERRNO("failed to poll");
break;
}
if (fds[0].revents & POLLIN) {
ret = 0;