From: octo Date: Sun, 18 Dec 2005 22:05:58 +0000 (+0000) Subject: Applied sigterm patch X-Git-Tag: collectd-3.5.1~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=16d700dfe2ef03b2ff34c04021337481df93489b;p=collectd.git Applied sigterm patch --- 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