summaryrefslogtreecommitdiff
path: root/bin/ksh/io.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-11-10 21:26:40 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-11-10 21:26:40 +0000
commitde8e8de6b77224e8b2ac3c698fbc2dabb934f77b (patch)
treed900abc4c52849fcd9a047dec413fa759453d5c3 /bin/ksh/io.c
parent507ab8275b041b65d552f065abafff05c014342e (diff)
If "from fd" == "to fd" don't call dup2() or close "from fd".
Diffstat (limited to 'bin/ksh/io.c')
-rw-r--r--bin/ksh/io.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/ksh/io.c b/bin/ksh/io.c
index 283488656a5..a20ceed3d8b 100644
--- a/bin/ksh/io.c
+++ b/bin/ksh/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.12 2003/03/10 03:48:16 david Exp $ */
+/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
/*
* shell buffered IO and formatted output
@@ -321,7 +321,7 @@ restfd(fd, ofd)
shf_flush(&shf_iob[fd]);
if (ofd < 0) /* original fd closed */
close(fd);
- else {
+ else if (fd != ofd) {
ksh_dup2(ofd, fd, TRUE); /* XXX: what to do if this fails? */
close(ofd);
}