static int max(const int a, const int b) { return (a > b) ? a : b; }
static void wait_until_readable(const int fd) {
- int select_ret;
fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(fd, &read_fds);
- if ((select_ret = select(fd + 1, &read_fds, NULL, NULL, NULL)) == -1)
+ int select_ret = select(fd + 1, &read_fds, NULL, NULL, NULL);
+ if (select_ret == -1) {
+ if (errno == EINTR) {
+ assert(stopping); // that should have been SIGTERM
+ return;
+ }
err(1, "select() failed");
+ }
if (!FD_ISSET(fd, &read_fds))
errx(1, "select() did not return readable fd = %d", fd);
}