diff --git a/src/exec.c b/src/exec.c
index 88026b662a0be208daa58b24c418357a1c63399a..c2d42ee0bbcc19f4268ab568ea45971ba70b92df 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
/*
* Functions
*/
-static void sigchld_handler (int signal) /* {{{ */
+static void sigchld_handler (int __attribute__((unused)) signal) /* {{{ */
{
pid_t pid;
int status;
{
if (strncasecmp ("PUTVAL", buffer, strlen ("PUTVAL")) == 0)
return (handle_putval (stdout, buffer));
-#if !COLLECT_DEBUG
-#error "TODO: PUTNOTIF"
- else if (strcasecmp (fields[1], "putnotif") == 0)
- return (handle_putnotif (stdout, fields + 1, fields_num));
-#endif
+ else if (strncasecmp ("PUTNOTIF", buffer, strlen ("PUTNOTIF")) == 0)
+ return (handle_putnotif (stdout, buffer));
else
{
/* For backwards compatibility */
if (errno == EAGAIN || errno == EINTR) continue;
break;
}
- else if (len == 0) break; /* We've reached EOF */
+ else if (len == 0)
+ {
+ /* We've reached EOF */
+ NOTICE ("exec plugin: Program `%s' has closed STDERR.",
+ pl->exec);
+ close (fd_err);
+ FD_CLR (fd_err, &fdset);
+ highest_fd = fd;
+ fd_err = -1;
+ continue;
+ }
pbuffer_err[len] = '\0';
copy = fdset;
}
+ DEBUG ("exec plugin: exec_read_one: Waiting for `%s' to exit.", pl->exec);
if (waitpid (pl->pid, &status, 0) > 0)
pl->status = status;
pthread_mutex_unlock (&pl_lock);
close (fd);
- close (fd_err);
+ if (fd_err >= 0)
+ close (fd_err);
pthread_exit ((void *) 0);
return (NULL);
for (meta = n->meta; meta != NULL; meta = meta->next)
{
if (meta->type == NM_TYPE_STRING)
- fprintf (fh, "%s: %s\n", meta->name, meta->value_string);
+ fprintf (fh, "%s: %s\n", meta->name, meta->nm_value.nm_string);
else if (meta->type == NM_TYPE_SIGNED_INT)
- fprintf (fh, "%s: %"PRIi64"\n", meta->name, meta->value_signed_int);
+ fprintf (fh, "%s: %"PRIi64"\n", meta->name, meta->nm_value.nm_signed_int);
else if (meta->type == NM_TYPE_UNSIGNED_INT)
- fprintf (fh, "%s: %"PRIu64"\n", meta->name, meta->value_unsigned_int);
+ fprintf (fh, "%s: %"PRIu64"\n", meta->name, meta->nm_value.nm_unsigned_int);
else if (meta->type == NM_TYPE_DOUBLE)
- fprintf (fh, "%s: %e\n", meta->name, meta->value_double);
+ fprintf (fh, "%s: %e\n", meta->name, meta->nm_value.nm_double);
else if (meta->type == NM_TYPE_BOOLEAN)
fprintf (fh, "%s: %s\n", meta->name,
- meta->value_boolean ? "true" : "false");
+ meta->nm_value.nm_boolean ? "true" : "false");
}
fprintf (fh, "\n%s\n", n->message);
DEBUG ("exec plugin: Child %i exited with status %i.",
pid, status);
- plugin_notification_meta_free (n);
+ plugin_notification_meta_free (n->meta);
+ n->meta = NULL;
sfree (arg);
pthread_exit ((void *) 0);
return (NULL);