struct timespec const timeout = { .tv_sec = 31, .tv_nsec = 0 };
struct tm tm;
int tick;
- sigset_t pending_signals;
- int signo;
while (true) {
if (clock_gettime(CLOCK_REALTIME, &ts) != 0)
if (timer_settime(main_timer, 0,
&its_disarm, NULL) != 0)
err(1, "timer_settime (disarm)");
- /* Clear any pending SIGALRM. */
- if (sigpending(&pending_signals) == -1)
- err(1, "sigpending");
- if (sigismember(&pending_signals, SIGALRM)) {
- errno = sigwait(&timing_signals, &signo);
- if (errno != 0)
- err(1, "sigwait");
- }
+ /* Clear any SIGALRM generated before timer disarmed */
+ if (sigtimedwait(&timing_signals, NULL, &TS_SEC(0))
+ == -1 && errno != EAGAIN)
+ err(1, "sigtimedwait");
}
}
}