netapp plugin: Fix a typo.
[collectd.git] / src / exec.c
index 4405985..acc6cf6 100644 (file)
@@ -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);