From e212659a6c9b99aa25a595ada727ed0f55d5d86e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 4 Sep 2020 21:36:42 +0200 Subject: Use sigaction instead of signal and siginterrupt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- mongoclock.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'mongoclock.c') diff --git a/mongoclock.c b/mongoclock.c index d94fd28..cf34e6d 100644 --- a/mongoclock.c +++ b/mongoclock.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -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) { -- cgit v1.2.3-70-g09d2