diff options
author | Mattias Andrée <maandree@kth.se> | 2020-09-04 21:36:42 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2020-09-04 21:36:42 +0200 |
commit | e212659a6c9b99aa25a595ada727ed0f55d5d86e (patch) | |
tree | fbdb9c13341b0879032592f102dc7c147568063f | |
parent | Do not accept arguments (diff) | |
download | mongotimer-e212659a6c9b99aa25a595ada727ed0f55d5d86e.tar.gz mongotimer-e212659a6c9b99aa25a595ada727ed0f55d5d86e.tar.bz2 mongotimer-e212659a6c9b99aa25a595ada727ed0f55d5d86e.tar.xz |
Use sigaction instead of signal and siginterrupt
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | mongoclock.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/mongoclock.c b/mongoclock.c index d94fd28..cf34e6d 100644 --- a/mongoclock.c +++ b/mongoclock.c @@ -6,6 +6,7 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <time.h> #include <unistd.h> @@ -88,6 +89,7 @@ main(int argc, char *argv[]) int fd = -1; struct itimerspec itimerspec; uint64_t _overrun; + struct sigaction sigact; ARGBEGIN { default: @@ -111,14 +113,15 @@ main(int argc, char *argv[]) if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &itimerspec, NULL)) goto fail; - signal(SIGTERM, sigterm); - signal(SIGQUIT, sigterm); - signal(SIGINT, sigterm); - signal(SIGWINCH, sigwinch); - siginterrupt(SIGTERM, 1); - siginterrupt(SIGQUIT, 1); - siginterrupt(SIGINT, 1); - siginterrupt(SIGWINCH, 1); + memset(&sigact, 0, sizeof(sigact)); + + sigact.sa_handler = sigterm; + sigaction(SIGTERM, &sigact, NULL); + sigaction(SIGQUIT, &sigact, NULL); + sigaction(SIGINT, &sigact, NULL); + + sigact.sa_handler = sigwinch; + sigaction(SIGWINCH, &sigact, NULL); while (!caught_sigterm) { if (caught_sigwinch) { |