X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fexec.c;h=acc6cf6f12aa93ea7fc743e78cc378acaf78c29a;hb=9c98fa31ef50a6ff849d36cac4f5297faa6f7909;hp=4405985646fdf24d27e3ea25367e32965cb47ee7;hpb=5a7145dd5626503f411a4aed87f30fc0f9689c90;p=collectd.git diff --git a/src/exec.c b/src/exec.c index 44059856..acc6cf6f 100644 --- a/src/exec.c +++ b/src/exec.c @@ -265,6 +265,17 @@ static int exec_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* int exec_config }}} */ +static void set_environment (void) /* {{{ */ +{ + char buffer[1024]; + + ssnprintf (buffer, sizeof (buffer), "%i", interval_g); + setenv ("COLLECTD_INTERVAL", buffer, /* overwrite = */ 1); + + ssnprintf (buffer, sizeof (buffer), "%s", hostname_g); + setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1); +} /* }}} void set_environment */ + static void exec_child (program_list_t *pl) /* {{{ */ { int status; @@ -382,6 +393,15 @@ static void exec_child (program_list_t *pl) /* {{{ */ exit (-1); } /* void exec_child }}} */ +static void reset_signal_mask (void) /* {{{ */ +{ + sigset_t ss; + + memset (&ss, 0, sizeof (ss)); + sigemptyset (&ss); + sigprocmask (SIG_SETMASK, &ss, /* old mask = */ NULL); +} /* }}} void reset_signal_mask */ + /* * Creates three pipes (one for reading, one for writing and one for errors), * forks a child, sets up the pipes so that fd_in is connected to STDIN of @@ -468,6 +488,11 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err) close (fd_pipe_err[1]); } + set_environment (); + + /* Unblock all signals */ + reset_signal_mask (); + exec_child (pl); /* does not return */ } @@ -730,7 +755,8 @@ static void *exec_notification_one (void *arg) /* {{{ */ DEBUG ("exec plugin: Child %i exited with status %i.", pid, status); - plugin_notification_meta_free (n->meta); + if (n->meta != NULL) + plugin_notification_meta_free (n->meta); n->meta = NULL; sfree (arg); pthread_exit ((void *) 0);