From: guenther Date: Sun, 10 Aug 2014 02:44:26 +0000 (+0000) Subject: Replace F_DUPFD followed by setting FD_CLOEXEC with just F_DUPFD_CLOEXEC X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bf50f91730779ddd98675df65270c10900ed24ef;p=openbsd Replace F_DUPFD followed by setting FD_CLOEXEC with just F_DUPFD_CLOEXEC ok matthew@ millert@ --- diff --git a/bin/ksh/io.c b/bin/ksh/io.c index 93b2d822060..14f1e6c2fc4 100644 --- a/bin/ksh/io.c +++ b/bin/ksh/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.23 2013/12/17 16:37:06 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.24 2014/08/10 02:44:26 guenther Exp $ */ /* * shell buffered IO and formatted output @@ -237,7 +237,7 @@ savefd(int fd) int nfd; if (fd < FDBASE) { - nfd = fcntl(fd, F_DUPFD, FDBASE); + nfd = fcntl(fd, F_DUPFD_CLOEXEC, FDBASE); if (nfd < 0) { if (errno == EBADF) return -1; @@ -246,7 +246,6 @@ savefd(int fd) } } else nfd = fd; - fcntl(nfd, F_SETFD, FD_CLOEXEC); return nfd; } diff --git a/bin/ksh/tty.c b/bin/ksh/tty.c index 2751c5a2cf7..2fff3482c02 100644 --- a/bin/ksh/tty.c +++ b/bin/ksh/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.9 2006/03/14 22:08:01 deraadt Exp $ */ +/* $OpenBSD: tty.c,v 1.10 2014/08/10 02:44:26 guenther Exp $ */ #include "sh.h" #include @@ -38,14 +38,9 @@ tty_init(int init_ttystate) return; } } - if ((tty_fd = fcntl(tfd, F_DUPFD, FDBASE)) < 0) { + if ((tty_fd = fcntl(tfd, F_DUPFD_CLOEXEC, FDBASE)) < 0) { warningf(false, "j_ttyinit: dup of tty fd failed: %s", strerror(errno)); - } else if (fcntl(tty_fd, F_SETFD, FD_CLOEXEC) < 0) { - warningf(false, "j_ttyinit: can't set close-on-exec flag: %s", - strerror(errno)); - close(tty_fd); - tty_fd = -1; } else if (init_ttystate) tcgetattr(tty_fd, &tty_state); if (do_close)