summaryrefslogtreecommitdiffstats
path: root/bin/sh/redir.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-05-05 10:51:40 +0000
committerjilles <jilles@FreeBSD.org>2013-05-05 10:51:40 +0000
commit135786413b1346f647980e2c338087f41e2735a2 (patch)
treedaf1ba66bada98a9f310e8dfed5331cec9dd46cd /bin/sh/redir.c
parent42b8c0012b80efc0b1d1bacb9d5c45afd8a51301 (diff)
downloadFreeBSD-src-135786413b1346f647980e2c338087f41e2735a2.zip
FreeBSD-src-135786413b1346f647980e2c338087f41e2735a2.tar.gz
sh: Use O_CLOEXEC and F_DUPFD_CLOEXEC instead of separate fcntl() call.
Diffstat (limited to 'bin/sh/redir.c')
-rw-r--r--bin/sh/redir.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/bin/sh/redir.c b/bin/sh/redir.c
index fda094d2..855f317 100644
--- a/bin/sh/redir.c
+++ b/bin/sh/redir.c
@@ -121,7 +121,7 @@ redirect(union node *redir, int flags)
if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY) {
INTOFF;
- if ((i = fcntl(fd, F_DUPFD, 10)) == -1) {
+ if ((i = fcntl(fd, F_DUPFD_CLOEXEC, 10)) == -1) {
switch (errno) {
case EBADF:
i = CLOSED;
@@ -131,8 +131,7 @@ redirect(union node *redir, int flags)
error("%d: %s", fd, strerror(errno));
break;
}
- } else
- (void)fcntl(i, F_SETFD, FD_CLOEXEC);
+ }
sv->renamed[fd] = i;
INTON;
}
OpenPOWER on IntegriCloud