X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fexec.c;h=ea31b3022bea5d45f609276699faf37594379a91;hb=52f41fed6e32f66f5817a82ae175fd443084f8a3;hp=973cd52b713c21277a7d27233fa000effccc79c0;hpb=619f112a584fcd89d2e8df7781a0a01341188189;p=collectd.git diff --git a/src/exec.c b/src/exec.c index 973cd52b..ea31b302 100644 --- a/src/exec.c +++ b/src/exec.c @@ -1,6 +1,8 @@ /** * collectd - src/exec.c - * Copyright (C) 2007,2008 Florian octo Forster + * Copyright (C) 2007-2009 Florian octo Forster + * Copyright (C) 2007-2009 Sebastian Harl + * Copyright (C) 2008 Peter Holik * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,6 +19,8 @@ * * Authors: * Florian octo Forster + * Sebastian Harl + * Peter Holik **/ #include "collectd.h" @@ -585,7 +589,17 @@ static void *exec_read_one (void *arg) /* {{{ */ 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'; @@ -615,6 +629,7 @@ static void *exec_read_one (void *arg) /* {{{ */ 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; @@ -628,7 +643,8 @@ static void *exec_read_one (void *arg) /* {{{ */ pthread_mutex_unlock (&pl_lock); close (fd); - close (fd_err); + if (fd_err >= 0) + close (fd_err); pthread_exit ((void *) 0); return (NULL);