From 3930d7b5747701ab3238e5e58ef6103aa2f5b29d Mon Sep 17 00:00:00 2001 From: Quentin Armitage Date: Thu, 12 Nov 2015 12:09:47 +0000 Subject: Make parent process handle and propagate USR1/2 signals In order to be able to automate writing configuration and/or stats the signals USR1 and USR2 need to be able to be sent to the parent process since its pid can be read from /var/run/keepalived.pid. The parent then needs to propagate these signals to a vrrp child. Resolves issue #169. Signed-off-by: Quentin Armitage (cherry picked from commit 63126b219547c18ffd8d28f4433e0512d1e7118b) --- keepalived/core/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/keepalived/core/main.c b/keepalived/core/main.c index 7756867..1dc3654 100644 --- a/keepalived/core/main.c +++ b/keepalived/core/main.c @@ -88,15 +88,15 @@ start_keepalived(void) #endif } -/* SIGHUP handler */ +/* SIGHUP/USR1/USR2 handler */ void -sighup(void *v, int sig) +propogate_signal(void *v, int sig) { /* Signal child process */ if (vrrp_child > 0) - kill(vrrp_child, SIGHUP); - if (checkers_child > 0) - kill(checkers_child, SIGHUP); + kill(vrrp_child, sig); + if (checkers_child > 0 && sig == SIGHUP) + kill(checkers_child, sig); } /* Terminate handler */ @@ -123,7 +123,9 @@ void signal_init(void) { signal_handler_init(); - signal_set(SIGHUP, sighup, NULL); + signal_set(SIGHUP, propogate_signal, NULL); + signal_set(SIGUSR1, propogate_signal, NULL); + signal_set(SIGUSR2, propogate_signal, NULL); signal_set(SIGINT, sigend, NULL); signal_set(SIGTERM, sigend, NULL); signal_ignore(SIGPIPE); -- 1.7.12.1