diff options
author | jilles <jilles@FreeBSD.org> | 2013-05-05 10:51:40 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-05-05 10:51:40 +0000 |
commit | 135786413b1346f647980e2c338087f41e2735a2 (patch) | |
tree | daf1ba66bada98a9f310e8dfed5331cec9dd46cd /bin/sh/redir.c | |
parent | 42b8c0012b80efc0b1d1bacb9d5c45afd8a51301 (diff) | |
download | FreeBSD-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.c | 5 |
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; } |