diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-10-07 22:51:55 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-10-07 22:53:39 -0400 |
commit | b8f1f91cc6d7b579fdb2370ab046565f9930aa09 (patch) | |
tree | f4bed1003ca36419f344d5540fa1cd32da220518 /libc/misc/utmp/utent.c | |
parent | 49b5ce384740ebabfc8e38dff6e37913e224dd29 (diff) |
clean up O_CLOEXEC handling
Drop the "#ifndef O_CLOEXEC" cruft, enable O_CLOEXEC in most fcntl.h
headers, and import __ASSUME_O_CLOEXEC from glibc.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libc/misc/utmp/utent.c')
-rw-r--r-- | libc/misc/utmp/utent.c | 21 |
1 files changed, 4 insertions, 17 deletions
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); |