When an executed program is closing STDERR but continues running, the
daemon will wait for the child to exit and the child will eventually
block because the pipe is filled up, resulting in no statistics being
collected.
Thanks to Thorsten von Eicken for finding this problem :)
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);