From dc0b5c71ffa2608bb63b1b2e63f52768681959c1 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 12 Sep 2012 18:25:20 +0200 Subject: [PATCH] exec plugin: Really remove STDERR from the select() set. select(2) is actually using a variable called "copy", which we didn't set in this case. Fixes Github issue #12. Thanks to Tetsuya Kawaguchi for reporting this problem. --- src/exec.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/exec.c b/src/exec.c index dd295e98..52747977 100644 --- a/src/exec.c +++ b/src/exec.c @@ -637,17 +637,22 @@ static void *exec_read_one (void *arg) /* {{{ */ 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; } -- 2.11.0