diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-11-10 21:26:40 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-11-10 21:26:40 +0000 |
commit | de8e8de6b77224e8b2ac3c698fbc2dabb934f77b (patch) | |
tree | d900abc4c52849fcd9a047dec413fa759453d5c3 /bin/ksh/eval.c | |
parent | 507ab8275b041b65d552f065abafff05c014342e (diff) |
If "from fd" == "to fd" don't call dup2() or close "from fd".
Diffstat (limited to 'bin/ksh/eval.c')
-rw-r--r-- | bin/ksh/eval.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c index 8f998cf2283..cf29ff9fee4 100644 --- a/bin/ksh/eval.c +++ b/bin/ksh/eval.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eval.c,v 1.13 2003/04/16 23:11:52 tdeval Exp $ */ +/* $OpenBSD: eval.c,v 1.14 2003/11/10 21:26:39 millert Exp $ */ /* * Expansion - quoting, separation, substitution, globbing @@ -874,8 +874,10 @@ comsub(xp, cp) openpipe(pv); shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0); ofd1 = savefd(1, 0); /* fd 1 may be closed... */ - ksh_dup2(pv[1], 1, FALSE); - close(pv[1]); + if (pv[1] != 1) { + ksh_dup2(pv[1], 1, FALSE); + close(pv[1]); + } execute(t, XFORK|XXCOM|XPIPEO); restfd(1, ofd1); startlast(); |