diff options
Diffstat (limited to 'libc/misc')
-rw-r--r-- | libc/misc/dirent/opendir.c | 8 | ||||
-rw-r--r-- | libc/misc/utmp/utent.c | 21 |
2 files changed, 7 insertions, 22 deletions
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c index e85dd3003..b43f60814 100644 --- a/libc/misc/dirent/opendir.c +++ b/libc/misc/dirent/opendir.c @@ -81,9 +81,6 @@ DIR *opendir(const char *name) } # define O_DIRECTORY 0 #endif -#ifndef O_CLOEXEC -# define O_CLOEXEC 0 -#endif fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY|O_CLOEXEC); if (fd < 0) return NULL; @@ -104,8 +101,9 @@ DIR *opendir(const char *name) /* According to POSIX, directory streams should be closed when * exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>. */ - if (O_CLOEXEC == 0) - fcntl(fd, F_SETFD, FD_CLOEXEC); +#ifndef __ASSUME_O_CLOEXEC + fcntl(fd, F_SETFD, FD_CLOEXEC); +#endif ptr = fd_to_DIR(fd, statbuf.st_blksize); if (!ptr) { diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c index beb00591c..336c0239b 100644 --- a/libc/misc/utmp/utent.c +++ b/libc/misc/utmp/utent.c @@ -34,9 +34,6 @@ static const char *static_ut_name = default_file_name; static void __setutent(void) { if (static_fd < 0) { -#ifndef O_CLOEXEC -# define O_CLOEXEC 0 -#endif static_fd = open(static_ut_name, O_RDWR | O_CLOEXEC); if (static_fd < 0) { static_fd = open(static_ut_name, O_RDONLY | O_CLOEXEC); @@ -44,20 +41,10 @@ static void __setutent(void) return; /* static_fd remains < 0 */ } } - if (O_CLOEXEC == 0) { - /* Make sure the file will be closed on exec() */ - fcntl(static_fd, F_SETFD, FD_CLOEXEC); - /* thus far, {G,S}ETFD only has this single flag, - * and setting it never fails. - *int ret = fcntl(static_fd, F_GETFD, 0); - *if (ret >= 0) { - * ret = fcntl(static_fd, F_SETFD, ret | FD_CLOEXEC); - *} - *if (ret < 0) { - * static_fd = -1; - *} - */ - } +#ifndef __ASSUME_O_CLOEXEC + /* Make sure the file will be closed on exec() */ + fcntl(static_fd, F_SETFD, FD_CLOEXEC); +#endif return; } lseek(static_fd, 0, SEEK_SET); |