From 16d700dfe2ef03b2ff34c04021337481df93489b Mon Sep 17 00:00:00 2001 From: octo Date: Sun, 18 Dec 2005 22:05:58 +0000 Subject: [PATCH] Applied sigterm patch --- src/collectd.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/collectd.c b/src/collectd.c index 97945775..4fdfcf10 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -53,6 +53,11 @@ static void sigIntHandler (int signal) loop++; } +static void sigTermHandler (int signal) +{ + loop++; +} + static int change_basedir (char *dir) { int dirlen = strlen (dir); @@ -249,8 +254,10 @@ static int pidfile_remove (const char *file) int main (int argc, char **argv) { - struct sigaction sigIntAction, sigChldAction; + struct sigaction sigIntAction; + struct sigaction sigTermAction; #if COLLECT_DAEMON + struct sigaction sigChldAction; pid_t pid; #endif @@ -347,18 +354,12 @@ int main (int argc, char **argv) } /* - * install signal handlers + * fork off child */ - sigIntAction.sa_handler = sigIntHandler; - sigaction (SIGINT, &sigIntAction, NULL); - +#if COLLECT_DAEMON sigChldAction.sa_handler = SIG_IGN; sigaction (SIGCHLD, &sigChldAction, NULL); - /* - * fork off child - */ -#if COLLECT_DAEMON if (daemonize) { if ((pid = fork ()) == -1) @@ -405,6 +406,15 @@ int main (int argc, char **argv) #endif /* COLLECT_DAEMON */ /* + * install signal handlers + */ + sigIntAction.sa_handler = sigIntHandler; + sigaction (SIGINT, &sigIntAction, NULL); + + sigIntAction.sa_handler = sigTermHandler; + sigaction (SIGTERM, &sigTermAction, NULL); + + /* * run the actual loops */ #if HAVE_LIBRRD -- 2.11.0