summaryrefslogtreecommitdiffstats
path: root/bin/sh/redir.c
diff options
context:
space:
mode:
authorbabkin <babkin@FreeBSD.org>2002-01-13 14:37:40 +0000
committerbabkin <babkin@FreeBSD.org>2002-01-13 14:37:40 +0000
commit6f66434b4f3ccf2ad05c9b816fc9724616d0a323 (patch)
tree667197655de954008632eaa96939ea2fbe9f3bbc /bin/sh/redir.c
parentccc42db0d5cbb002bfdc95cae12abf0ab19048dc (diff)
downloadFreeBSD-src-6f66434b4f3ccf2ad05c9b816fc9724616d0a323.zip
FreeBSD-src-6f66434b4f3ccf2ad05c9b816fc9724616d0a323.tar.gz
The fix for >/dev/stdout, including Tor Egge's fix for the bug in the
original attempt of the fix. And yes, this time I've tried to build world with it and it succeeded. Submitted by: Tor Egge MFC after: 1 week
Diffstat (limited to 'bin/sh/redir.c')
-rw-r--r--bin/sh/redir.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/bin/sh/redir.c b/bin/sh/redir.c
index ee893f4..b51fa2b 100644
--- a/bin/sh/redir.c
+++ b/bin/sh/redir.c
@@ -145,11 +145,8 @@ again:
}
if (!try) {
sv->renamed[fd] = i;
- close(fd);
}
INTON;
- } else {
- close(fd);
}
if (fd == 0)
fd0_redirected++;
@@ -186,6 +183,7 @@ openredirect(redir, memory)
error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
movefd:
if (f != fd) {
+ close(fd);
copyfd(f, fd);
close(f);
}
@@ -238,8 +236,10 @@ movefd:
if (redir->ndup.dupfd >= 0) { /* if not ">&-" */
if (memory[redir->ndup.dupfd])
memory[fd] = 1;
- else
+ else {
+ close(fd);
copyfd(redir->ndup.dupfd, fd);
+ }
}
break;
case NHERE:
OpenPOWER on IntegriCloud