projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
23fccc7
)
exec plugin: Close all file descriptors but the one connected to the pipe.
author
Florian Forster
<octo@crystal.wlan.home.verplant.org>
Wed, 9 Apr 2008 16:32:14 +0000
(18:32 +0200)
committer
Florian Forster
<octo@crystal.wlan.home.verplant.org>
Wed, 9 Apr 2008 16:32:14 +0000
(18:32 +0200)
src/exec.c
patch
|
blob
|
history
diff --git
a/src/exec.c
b/src/exec.c
index
0ab259d
..
52dd831
100644
(file)
--- a/
src/exec.c
+++ b/
src/exec.c
@@
-264,7
+264,17
@@
static int fork_child (program_list_t *pl)
}
else if (pl->pid == 0)
{
- close (fd_pipe[0]);
+ int fd_num;
+ int fd;
+
+ /* Close all file descriptors but the pipe end we need. */
+ fd_num = getdtablesize ();
+ for (fd = 0; fd < fd_num; fd++)
+ {
+ if (fd == fd_pipe[1])
+ continue;
+ close (fd);
+ }
/* Connect the pipe to STDOUT and STDERR */
if (fd_pipe[1] != STDOUT_FILENO)