uloop: add back support for overriding signal handlers when signalfd is in use
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
004be15be4
commit
93be9309b8
2 changed files with 21 additions and 6 deletions
|
@ -29,6 +29,7 @@ static void
|
||||||
uloop_signal_fd_cb(struct uloop_fd *fd, unsigned int events)
|
uloop_signal_fd_cb(struct uloop_fd *fd, unsigned int events)
|
||||||
{
|
{
|
||||||
struct signalfd_siginfo fdsi;
|
struct signalfd_siginfo fdsi;
|
||||||
|
struct sigaction act;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
|
@ -39,7 +40,22 @@ retry:
|
||||||
if (ret != sizeof(fdsi))
|
if (ret != sizeof(fdsi))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
switch (fdsi.ssi_signo) {
|
||||||
|
case SIGQUIT:
|
||||||
|
case SIGINT:
|
||||||
|
case SIGTERM:
|
||||||
|
sigaction(fdsi.ssi_signo, NULL, &act);
|
||||||
|
if (act.sa_handler != SIG_IGN &&
|
||||||
|
act.sa_handler != SIG_DFL) {
|
||||||
|
act.sa_handler(fdsi.ssi_signo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fall through */
|
||||||
|
default:
|
||||||
uloop_handle_signal(fdsi.ssi_signo);
|
uloop_handle_signal(fdsi.ssi_signo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -58,7 +74,7 @@ uloop_setup_signalfd(bool add)
|
||||||
|
|
||||||
if (!add) {
|
if (!add) {
|
||||||
uloop_fd_delete(&sfd);
|
uloop_fd_delete(&sfd);
|
||||||
sigprocmask(SIG_SETMASK, &prev_mask, NULL);
|
sigprocmask(SIG_BLOCK, &prev_mask, NULL);
|
||||||
} else {
|
} else {
|
||||||
sigaddset(&mask, SIGQUIT);
|
sigaddset(&mask, SIGQUIT);
|
||||||
sigaddset(&mask, SIGINT);
|
sigaddset(&mask, SIGINT);
|
||||||
|
|
7
uloop.c
7
uloop.c
|
@ -392,14 +392,13 @@ static void uloop_ignore_signal(int signum, bool ignore)
|
||||||
|
|
||||||
static void uloop_setup_signals(bool add)
|
static void uloop_setup_signals(bool add)
|
||||||
{
|
{
|
||||||
static struct sigaction old_sigint, old_sigchld, old_sigterm;
|
static struct sigaction old_sigint, old_sigchld, old_sigterm, old_sigquit;
|
||||||
|
|
||||||
if (uloop_setup_signalfd(add))
|
uloop_setup_signalfd(add);
|
||||||
return;
|
|
||||||
|
|
||||||
uloop_install_handler(SIGINT, uloop_handle_signal, &old_sigint, add);
|
uloop_install_handler(SIGINT, uloop_handle_signal, &old_sigint, add);
|
||||||
uloop_install_handler(SIGTERM, uloop_handle_signal, &old_sigterm, add);
|
uloop_install_handler(SIGTERM, uloop_handle_signal, &old_sigterm, add);
|
||||||
uloop_install_handler(SIGQUIT, uloop_handle_signal, &old_sigterm, add);
|
uloop_install_handler(SIGQUIT, uloop_handle_signal, &old_sigquit, add);
|
||||||
uloop_install_handler(SIGCHLD, uloop_handle_signal, &old_sigchld, add);
|
uloop_install_handler(SIGCHLD, uloop_handle_signal, &old_sigchld, add);
|
||||||
|
|
||||||
uloop_ignore_signal(SIGPIPE, add);
|
uloop_ignore_signal(SIGPIPE, add);
|
||||||
|
|
Loading…
Reference in a new issue