diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:49:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 12:42:05 +0000 |
commit | 2e85f9325a797977eea9dfea0a925775ddd211d9 (patch) | |
tree | 452c7f30d62fca5755f659b99e4e53c7b03afc21 /collectors/nfacct.plugin/plugin_nfacct.c | |
parent | Releasing debian version 1.19.0-4. (diff) | |
download | netdata-2e85f9325a797977eea9dfea0a925775ddd211d9.tar.xz netdata-2e85f9325a797977eea9dfea0a925775ddd211d9.zip |
Merging upstream version 1.29.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/nfacct.plugin/plugin_nfacct.c')
-rw-r--r-- | collectors/nfacct.plugin/plugin_nfacct.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/collectors/nfacct.plugin/plugin_nfacct.c b/collectors/nfacct.plugin/plugin_nfacct.c index 21c2e4aee..996070f1c 100644 --- a/collectors/nfacct.plugin/plugin_nfacct.c +++ b/collectors/nfacct.plugin/plugin_nfacct.c @@ -762,6 +762,30 @@ static void nfacct_send_metrics() { #endif // HAVE_LIBNETFILTER_ACCT +static void nfacct_signal_handler(int signo) +{ + exit((signo == SIGPIPE)?1:0); +} + +// When Netdata crashes this plugin was becoming zombie, +// this function was added to remove it when sigpipe and other signals are received. +void nfacct_signals() +{ + int signals[] = { SIGPIPE, SIGINT, SIGTERM, 0}; + int i; + struct sigaction sa; + sa.sa_flags = 0; + sa.sa_handler = nfacct_signal_handler; + + // ignore all signals while we run in a signal handler + sigfillset(&sa.sa_mask); + + for (i = 0; signals[i]; i++) { + if(sigaction(signals[i], &sa, NULL) == -1) + error("Cannot add the handler to signal %d", signals[i]); + } +} + int main(int argc, char **argv) { // ------------------------------------------------------------------------ @@ -833,6 +857,8 @@ int main(int argc, char **argv) { error("nfacct.plugin: ignoring parameter '%s'", argv[i]); } + nfacct_signals(); + errno = 0; if(freq >= netdata_update_every) |