Correct ba046c02c7
.
Apparently I had forgotten the counter-intuitive semantics of
signalfd(): it's necessary to BLOCK the signals that will be
handled exclusively by signalfd() so that the default POSIX
signal handling mechanism won't intercept the signals first.
The lack of response to ctrl+c is a legitimate bug that is
now properly fixed; ba046c02c7
fixed that issue, but
regressed the handling of other signals.
This commit is contained in:
parent
32bc422d0e
commit
f0340b1475
@ -166,7 +166,8 @@ static void setup_signals_ndhc(void)
|
|||||||
sigaddset(&mask, SIGUSR2);
|
sigaddset(&mask, SIGUSR2);
|
||||||
sigaddset(&mask, SIGCHLD);
|
sigaddset(&mask, SIGCHLD);
|
||||||
sigaddset(&mask, SIGTERM);
|
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");
|
suicide("sigprocmask failed");
|
||||||
if (cs.signalFd >= 0) {
|
if (cs.signalFd >= 0) {
|
||||||
epoll_del(cs.epollFd, cs.signalFd);
|
epoll_del(cs.epollFd, cs.signalFd);
|
||||||
@ -201,6 +202,9 @@ static int signal_dispatch(void)
|
|||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
log_line("Received SIGTERM. Exiting gracefully.");
|
log_line("Received SIGTERM. Exiting gracefully.");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
case SIGINT:
|
||||||
|
log_line("Received SIGINT. Exiting gracefully.");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
default: return SIGNAL_NONE;
|
default: return SIGNAL_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ int setup_signals_subprocess(void)
|
|||||||
sigaddset(&mask, SIGHUP);
|
sigaddset(&mask, SIGHUP);
|
||||||
sigaddset(&mask, SIGINT);
|
sigaddset(&mask, SIGINT);
|
||||||
sigaddset(&mask, SIGTERM);
|
sigaddset(&mask, SIGTERM);
|
||||||
if (sigprocmask(SIG_UNBLOCK, &mask, (sigset_t *)0) < 0)
|
if (sigprocmask(SIG_BLOCK, &mask, (sigset_t *)0) < 0)
|
||||||
suicide("sigprocmask failed");
|
suicide("sigprocmask failed");
|
||||||
int sfd = signalfd(-1, &mask, SFD_NONBLOCK);
|
int sfd = signalfd(-1, &mask, SFD_NONBLOCK);
|
||||||
if (sfd < 0)
|
if (sfd < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user