From 6127be18062e129a74f66449f1ef3c465af58168 Mon Sep 17 00:00:00 2001 From: Jan Friesse Date: Wed, 12 Dec 2012 09:25:18 +0100 Subject: [PATCH] Move qb_loop creation after daemonization Creating qb_loop before daemonization is not problem for poll or epoll type loops, but it's problem for kqueue, because kqueue is not shared in child with parent after fork. Signed-off-by: Jan Friesse Reviewed-by: Fabio M. Di Nitto --- exec/main.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/exec/main.c b/exec/main.c index abd8fbda..6a5dc45c 100644 --- a/exec/main.c +++ b/exec/main.c @@ -1088,16 +1088,9 @@ int main (int argc, char **argv, char **envp) log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.", VERSION); log_printf (LOGSYS_LEVEL_INFO, "Corosync built-in features:" PACKAGE_FEATURES ""); - corosync_poll_handle = qb_loop_create (); - - qb_loop_signal_add(corosync_poll_handle, QB_LOOP_LOW, - SIGUSR2, NULL, sig_diag_handler, NULL); - qb_loop_signal_add(corosync_poll_handle, QB_LOOP_HIGH, - SIGINT, NULL, sig_exit_handler, NULL); - qb_loop_signal_add(corosync_poll_handle, QB_LOOP_HIGH, - SIGQUIT, NULL, sig_exit_handler, NULL); - qb_loop_signal_add(corosync_poll_handle, QB_LOOP_HIGH, - SIGTERM, NULL, sig_exit_handler, NULL); + /* + * Other signals are registered later via qb_loop_signal_add + */ (void)signal (SIGSEGV, sigsegv_handler); (void)signal (SIGABRT, sigabrt_handler); #if MSG_NOSIGNAL != 0 @@ -1199,6 +1192,18 @@ int main (int argc, char **argv, char **envp) if (background) { corosync_tty_detach (); } + + corosync_poll_handle = qb_loop_create (); + + qb_loop_signal_add(corosync_poll_handle, QB_LOOP_LOW, + SIGUSR2, NULL, sig_diag_handler, NULL); + qb_loop_signal_add(corosync_poll_handle, QB_LOOP_HIGH, + SIGINT, NULL, sig_exit_handler, NULL); + qb_loop_signal_add(corosync_poll_handle, QB_LOOP_HIGH, + SIGQUIT, NULL, sig_exit_handler, NULL); + qb_loop_signal_add(corosync_poll_handle, QB_LOOP_HIGH, + SIGTERM, NULL, sig_exit_handler, NULL); + if (logsys_thread_start() != 0) { log_printf (LOGSYS_LEVEL_ERROR, "Can't initialize log thread"); corosync_exit_error (COROSYNC_DONE_LOGCONFIGREAD); -- 2.39.5