This saves a syscall on every source file open, &c.; F_DUPFD_CLOEXEC is a mandatory part of POSIX since Issue 7 (Austin Group Interpretation 1003.1-2001 #171). --- src/redir.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/redir.c b/src/redir.c index 5a5835c..9fee74f 100644 --- a/src/redir.c +++ b/src/redir.c @@ -446,14 +446,12 @@ savefd(int from, int ofd) int newfd; int err; - newfd = fcntl(from, F_DUPFD, 10); + newfd = fcntl(from, F_DUPFD_CLOEXEC, 10); err = newfd < 0 ? errno : 0; if (err != EBADF) { close(ofd); if (err) sh_error("%d: %s", from, strerror(err)); - else - fcntl(newfd, F_SETFD, FD_CLOEXEC); } return newfd; -- 2.30.2
Attachment:
signature.asc
Description: PGP signature