summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2470aaf)
raw | patch | inline | side by side (parent: 2470aaf)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 28 Sep 2008 19:25:40 +0000 (19:25 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 28 Sep 2008 19:25:40 +0000 (19:25 +0000) |
in preparation for new signals. Documented behavior of existing signals.
-- kevin brintnall
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1539 a5681a0c-68f1-0310-ab6d-d61299d08faa
-- kevin brintnall
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1539 a5681a0c-68f1-0310-ab6d-d61299d08faa
doc/rrdcached.pod | patch | blob | history | |
src/rrd_daemon.c | patch | blob | history |
diff --git a/doc/rrdcached.pod b/doc/rrdcached.pod
index 9254888e8306b2d6dad7a087a78837072516fc90..d8d88c59e520de524a8d72fdc274d53baff24fcb 100644 (file)
--- a/doc/rrdcached.pod
+++ b/doc/rrdcached.pod
=back
+=head1 SIGNALS
+
+=over 4
+
+=item SIGINT and SIGTERM
+
+The daemon exits normally on receipt of either of these signals.
+
+=back
+
=head1 BUGS
No known bugs at the moment.
diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
index 0e29f131ab1387fa657ae0160e2e6d956de4bab7..a0b836487f8e9c3d3be5b5258cdd9042c3df459b 100644 (file)
--- a/src/rrd_daemon.c
+++ b/src/rrd_daemon.c
/*
* Functions
*/
-static void sig_int_handler (int s __attribute__((unused))) /* {{{ */
+static void sig_common (const char *sig) /* {{{ */
{
- RRDD_LOG(LOG_NOTICE, "caught SIGINT");
+ RRDD_LOG(LOG_NOTICE, "caught SIG%s", sig);
do_shutdown++;
pthread_cond_broadcast(&cache_cond);
+} /* }}} void sig_common */
+
+static void sig_int_handler (int s __attribute__((unused))) /* {{{ */
+{
+ sig_common("INT");
} /* }}} void sig_int_handler */
static void sig_term_handler (int s __attribute__((unused))) /* {{{ */
{
- RRDD_LOG(LOG_NOTICE, "caught SIGTERM");
- do_shutdown++;
- pthread_cond_broadcast(&cache_cond);
+ sig_common("TERM");
} /* }}} void sig_term_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;
+
+ /* 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);
+
+} /* }}} void install_signal_handlers */
+
static int open_pidfile(void) /* {{{ */
{
int fd;
int status;
int fd;
- /* 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;
-
fd = open_pidfile();
if (fd < 0) return fd;
dup (0);
} /* if (!stay_foreground) */
- /* 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);
+ install_signal_handlers();
openlog ("rrdcached", LOG_PID, LOG_DAEMON);
RRDD_LOG(LOG_INFO, "starting up");