diff --git a/src/exec.c b/src/exec.c
index 34c88a1ce6eb65e801bed579da1ea57e72a2e8b7..9e3a20e6e26b0551807e5e312ba33c16e167dc3e 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
@@ -491,7 +491,7 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
close (fd_pipe_out[1]);
}
- /* Now connect the `out' pipe to STDOUT */
+ /* Now connect the `err' pipe to STDERR */
if (fd_pipe_err[1] != STDERR_FILENO)
{
dup2 (fd_pipe_err[1], STDERR_FILENO);
if (len < 0)
{
- if (errno == EAGAIN || errno == EINTR) continue;
+ if (errno == EAGAIN || errno == EINTR)
+ continue;
break;
}
else if (len == 0)
{
/* We've reached EOF */
- NOTICE ("exec plugin: Program `%s' has closed STDERR.",
- pl->exec);
- close (fd_err);
+ NOTICE ("exec plugin: Program `%s' has closed STDERR.", pl->exec);
+
+ /* Remove file descriptor form select() set. */
FD_CLR (fd_err, &fdset);
+ copy = fdset;
highest_fd = fd;
+
+ /* Clean up file descriptor */
+ close (fd_err);
fd_err = -1;
continue;
}
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
pthread_create (&t, &attr, exec_read_one, (void *) pl);
+ pthread_attr_destroy (&attr);
} /* for (pl) */
return (0);
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
pthread_create (&t, &attr, exec_notification_one, (void *) pln);
+ pthread_attr_destroy (&attr);
} /* for (pl) */
return (0);