aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-07 00:16:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-07 00:16:31 +0000
commit6e2cdf0d30c4ba6c86d6fa67cf47001506e12677 (patch)
tree37e761a6bef121082e4aeab4bf6486df72475256
parent6461dbbcb47c6b1be786eb5c3d5a39f97f5dfb3d (diff)
downloadpaludis-6e2cdf0d30c4ba6c86d6fa67cf47001506e12677.tar.gz
paludis-6e2cdf0d30c4ba6c86d6fa67cf47001506e12677.tar.xz
Can close() dup()ed fd sources too
-rw-r--r--paludis/util/system.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/paludis/util/system.cc b/paludis/util/system.cc
index e17fd93..918fba9 100644
--- a/paludis/util/system.cc
+++ b/paludis/util/system.cc
@@ -611,11 +611,13 @@ paludis::run_command(const Command & cmd)
{
if (-1 == dup2(captured_stdout->write_fd(), 1))
throw RunCommandError("captured stdout dup2 failed: " + stringify(strerror(errno)));
+ close(captured_stdout->write_fd());
}
else if (-1 != stdout_write_fd)
{
if (-1 == dup2(stdout_write_fd, 1))
throw RunCommandError("stdout dup2 failed: " + stringify(strerror(errno)));
+ close(stdout_write_fd);
if (-1 != stdout_close_fd)
close(stdout_close_fd);
@@ -625,11 +627,13 @@ paludis::run_command(const Command & cmd)
{
if (-1 == dup2(captured_stderr->write_fd(), 2))
throw RunCommandError("captured stderr dup2 failed: " + stringify(strerror(errno)));
+ close(captured_stderr->write_fd());
}
else if (-1 != stderr_write_fd)
{
if (-1 == dup2(stderr_write_fd, 2))
throw RunCommandError("stderr dup2 failed: " + stringify(strerror(errno)));
+ close(stderr_write_fd);
if (-1 != stderr_close_fd)
close(stderr_close_fd);