+static void sig_usr1_handler (int s __attribute__((unused))) /* {{{ */
+{
+ config_flush_at_shutdown = 1;
+ sig_common("USR1");
+} /* }}} void sig_usr1_handler */
+
+static void sig_usr2_handler (int s __attribute__((unused))) /* {{{ */
+{
+ config_flush_at_shutdown = 0;
+ sig_common("USR2");
+} /* }}} void sig_usr2_handler */
+
+static void install_signal_handlers(void) /* {{{ */
+{
+ /* These structures are static, because `sigaction' behaves weird if the are
+ * overwritten.. */
+ static struct sigaction sa_int;
+ static struct sigaction sa_term;
+ static struct sigaction sa_pipe;
+ static struct sigaction sa_usr1;
+ static struct sigaction sa_usr2;
+
+ /* Install signal handlers */
+ memset (&sa_int, 0, sizeof (sa_int));
+ sa_int.sa_handler = sig_int_handler;
+ sigaction (SIGINT, &sa_int, NULL);
+
+ memset (&sa_term, 0, sizeof (sa_term));
+ sa_term.sa_handler = sig_term_handler;
+ sigaction (SIGTERM, &sa_term, NULL);
+
+ memset (&sa_pipe, 0, sizeof (sa_pipe));
+ sa_pipe.sa_handler = SIG_IGN;
+ sigaction (SIGPIPE, &sa_pipe, NULL);
+
+ memset (&sa_pipe, 0, sizeof (sa_usr1));
+ sa_usr1.sa_handler = sig_usr1_handler;
+ sigaction (SIGUSR1, &sa_usr1, NULL);
+
+ memset (&sa_usr2, 0, sizeof (sa_usr2));
+ sa_usr2.sa_handler = sig_usr2_handler;
+ sigaction (SIGUSR2, &sa_usr2, NULL);
+
+} /* }}} void install_signal_handlers */
+
+static int open_pidfile(char *action, int oflag) /* {{{ */