summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/sh/redir.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bin/sh/redir.c b/bin/sh/redir.c
index 8c05da9..ee893f4 100644
--- a/bin/sh/redir.c
+++ b/bin/sh/redir.c
@@ -145,8 +145,11 @@ again:
}
if (!try) {
sv->renamed[fd] = i;
+ close(fd);
}
INTON;
+ } else {
+ close(fd);
}
if (fd == 0)
fd0_redirected++;
@@ -183,7 +186,6 @@ openredirect(redir, memory)
error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
movefd:
if (f != fd) {
- close(fd);
copyfd(f, fd);
close(f);
}
OpenPOWER on IntegriCloud