diff options
author | des <des@FreeBSD.org> | 2004-01-21 12:50:01 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2004-01-21 12:50:01 +0000 |
commit | 5bed8122fd9ad3746f9f6139eac42ce5041f08f4 (patch) | |
tree | 45b894f449c0d20308caae0992208804c1312206 /bin/sh/eval.c | |
parent | c939cff38891929d64b9b5a0d14e2cd42623a789 (diff) | |
download | FreeBSD-src-5bed8122fd9ad3746f9f6139eac42ce5041f08f4.zip FreeBSD-src-5bed8122fd9ad3746f9f6139eac42ce5041f08f4.tar.gz |
Replace home-grown dup2() implementation with actual dup2() calls. This
should slightly reduce the number of system calls in critical portions of
the shell, and select a more efficient path through the fdalloc code.
Reviewed by: bde
Diffstat (limited to 'bin/sh/eval.c')
-rw-r--r-- | bin/sh/eval.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index bf96c2f..38282d4 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -479,16 +479,14 @@ evalpipe(union node *n) if (forkshell(jp, lp->n, n->npipe.backgnd) == 0) { INTON; if (prevfd > 0) { - close(0); - copyfd(prevfd, 0); + dup2(prevfd, 0); close(prevfd); } if (pip[1] >= 0) { if (!(prevfd >= 0 && pip[0] == 0)) close(pip[0]); if (pip[1] != 1) { - close(1); - copyfd(pip[1], 1); + dup2(pip[1], 1); close(pip[1]); } } @@ -545,8 +543,7 @@ evalbackcmd(union node *n, struct backcmd *result) FORCEINTON; close(pip[0]); if (pip[1] != 1) { - close(1); - copyfd(pip[1], 1); + dup2(pip[1], 1); close(pip[1]); } evaltree(n, EV_EXIT); @@ -742,8 +739,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) FORCEINTON; close(pip[0]); if (pip[1] != 1) { - close(1); - copyfd(pip[1], 1); + dup2(pip[1], 1); close(pip[1]); } } |