diff --git a/src/ndhc.c b/src/ndhc.c index 62e55a9..e7ffaa8 100644 --- a/src/ndhc.c +++ b/src/ndhc.c @@ -166,7 +166,8 @@ static void setup_signals_ndhc(void) sigaddset(&mask, SIGUSR2); sigaddset(&mask, SIGCHLD); sigaddset(&mask, SIGTERM); - if (sigprocmask(SIG_UNBLOCK, &mask, (sigset_t *)0) < 0) + sigaddset(&mask, SIGINT); + if (sigprocmask(SIG_BLOCK, &mask, (sigset_t *)0) < 0) suicide("sigprocmask failed"); if (cs.signalFd >= 0) { epoll_del(cs.epollFd, cs.signalFd); @@ -201,6 +202,9 @@ static int signal_dispatch(void) case SIGTERM: log_line("Received SIGTERM. Exiting gracefully."); exit(EXIT_SUCCESS); + case SIGINT: + log_line("Received SIGINT. Exiting gracefully."); + exit(EXIT_SUCCESS); default: return SIGNAL_NONE; } } diff --git a/src/sys.c b/src/sys.c index 17b488a..548e4d8 100644 --- a/src/sys.c +++ b/src/sys.c @@ -77,7 +77,7 @@ int setup_signals_subprocess(void) sigaddset(&mask, SIGHUP); sigaddset(&mask, SIGINT); sigaddset(&mask, SIGTERM); - if (sigprocmask(SIG_UNBLOCK, &mask, (sigset_t *)0) < 0) + if (sigprocmask(SIG_BLOCK, &mask, (sigset_t *)0) < 0) suicide("sigprocmask failed"); int sfd = signalfd(-1, &mask, SFD_NONBLOCK); if (sfd < 0)