diff --git a/gpsd.c b/gpsd.c index d342f5a..5c0e8e1 100644 --- a/gpsd.c +++ b/gpsd.c @@ -9,6 +9,7 @@ #include #include #include /* for select() */ +#include #include #include #include @@ -1765,7 +1766,11 @@ int main(int argc, char *argv[]) int i, option, dfd; int msocks[2] = {-1, -1}; bool go_background = true; +#ifdef COMPAT_SELECT struct timeval tv; +#else + sigset_t emptyset, blockset; +#endif /* COMPAT_SELECT */ const struct gps_type_t **dp; bool in_restart; @@ -2050,6 +2055,14 @@ int main(int argc, char *argv[]) } /* Handle some signals */ +#ifndef COMPAT_SELECT + sigemptyset(&blockset); + sigaddset(&blockset, SIGHUP); + sigaddset(&blockset, SIGINT); + sigaddset(&blockset, SIGTERM); + sigaddset(&blockset, SIGQUIT); + sigprocmask(SIG_BLOCK, &blockset, &emptyset); +#endif /* COMPAT_SELECT */ signalled = 0; (void)signal(SIGHUP, onsig); (void)signal(SIGINT, onsig); @@ -2096,10 +2109,15 @@ int main(int argc, char *argv[]) * low-clock-rate SBCs and the like). */ /*@ -usedef @*/ + errno = 0; + +#ifdef COMPAT_SELECT tv.tv_sec = 1; tv.tv_usec = 0; - errno = 0; if (select(maxfd + 1, &rfds, NULL, NULL, &tv) == -1) { +#else + if (pselect(maxfd + 1, &rfds, NULL, NULL, NULL, &emptyset) == -1) { +#endif if (errno == EINTR) continue; gpsd_report(LOG_ERROR, "select: %s\n", strerror(errno));