diff options
author | babkin <babkin@FreeBSD.org> | 2002-01-13 14:37:40 +0000 |
---|---|---|
committer | babkin <babkin@FreeBSD.org> | 2002-01-13 14:37:40 +0000 |
commit | 6f66434b4f3ccf2ad05c9b816fc9724616d0a323 (patch) | |
tree | 667197655de954008632eaa96939ea2fbe9f3bbc /bin | |
parent | ccc42db0d5cbb002bfdc95cae12abf0ab19048dc (diff) | |
download | FreeBSD-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')
-rw-r--r-- | bin/sh/redir.c | 8 |
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: |