summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-08-03 11:26:44 +0200
committerToni Uhlig <matzeton@googlemail.com>2021-08-03 12:37:59 +0200
commit3a760355705761f46d57a70cca3a34834225ae97 (patch)
tree273a6ac4a44af6bb33df0a36c7cd9b5b969c3bed /examples
parentc32461b032fd2fec74821f3bd5c9bcc2c9689de2 (diff)
bump libnDPI to 6b7e5fa8d251f11c1bae16ea892a43a92b098480
* fixed linking issue by using CMake to check if explicit link against libm required * make nDPIsrvd collectd exit if parent pid changed, meaning that collectd died somehow * nDPId-test restores SIGPIPE to the default handler (termination), so abnormal connection drop's do now have consequences Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/c-collectd/c-collectd.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c
index 59f724773..d7d0819b4 100644
--- a/examples/c-collectd/c-collectd.c
+++ b/examples/c-collectd/c-collectd.c
@@ -26,6 +26,7 @@
static struct nDPIsrvd_socket * sock = NULL;
static int main_thread_shutdown = 0;
static int collectd_timerfd = -1;
+static pid_t collectd_pid;
static char * serv_optarg = NULL;
static char * collectd_hostname = NULL;
@@ -364,6 +365,16 @@ static int mainloop(int epollfd)
{
uint64_t expirations;
+ /*
+ * Check if collectd parent process is still running.
+ * May happen if collectd was killed with singals e.g. SIGKILL.
+ */
+ if (getppid() != collectd_pid)
+ {
+ LOG(LOG_DAEMON | LOG_ERR, "Parent process %d exited. Nothing left to do here, bye.", collectd_pid);
+ return 1;
+ }
+
errno = 0;
if (read(collectd_timerfd, &expirations, sizeof(expirations)) != sizeof(expirations))
{
@@ -693,6 +704,8 @@ int main(int argc, char ** argv)
signal(SIGTERM, sighandler);
signal(SIGPIPE, SIG_IGN);
+ collectd_pid = getppid();
+
int epollfd = epoll_create1(0);
if (epollfd < 0)
{