diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-04-18 14:42:19 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-04-18 14:42:19 +0200 |
commit | b48061e1a534a2421c65e4258418d41a5335ba32 (patch) | |
tree | 7b2a00fe1f6b7a9e9e6726c0bbfedd20506ad1b9 /libio/freopen.c | |
parent | 46d8874d5b2fcb7831dd84c5e2f6df51922a7936 (diff) | |
download | glibc-b48061e1a534a2421c65e4258418d41a5335ba32.tar.gz glibc-b48061e1a534a2421c65e4258418d41a5335ba32.tar.xz glibc-b48061e1a534a2421c65e4258418d41a5335ba32.zip |
Assume that dup3 is available
Diffstat (limited to 'libio/freopen.c')
-rw-r--r-- | libio/freopen.c | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/libio/freopen.c b/libio/freopen.c index 03e3ae77ba..ad1c848877 100644 --- a/libio/freopen.c +++ b/libio/freopen.c @@ -78,32 +78,9 @@ freopen (const char *filename, const char *mode, FILE *fp) if (fd != -1) { -#ifdef O_CLOEXEC -# ifndef __ASSUME_DUP3 - int newfd; - if (__have_dup3 < 0) - newfd = -1; - else - newfd = -# endif - __dup3 (_IO_fileno (result), fd, - (result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 - ? O_CLOEXEC : 0); -#else -# define newfd 1 -#endif - -#ifndef __ASSUME_DUP3 - if (newfd < 0) - { - if (errno == ENOSYS) - __have_dup3 = -1; - - __dup2 (_IO_fileno (result), fd); - if ((result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0) - __fcntl (fd, F_SETFD, FD_CLOEXEC); - } -#endif + __dup3 (_IO_fileno (result), fd, + (result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 + ? O_CLOEXEC : 0); __close (_IO_fileno (result)); _IO_fileno (result) = fd; } |