diff options
author | Mike Frysinger <vapier@gentoo.org> | 2011-07-19 16:05:52 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2011-11-20 02:47:50 -0500 |
commit | 117a32a63b837730cc97b0a233ab46e9abc6c7a7 (patch) | |
tree | 8a0f4b5fa2058c09f300c1701440a0864b4d5918 /libc/stdio/_fopen.c | |
parent | 4a2b0641a3818ad14b886907368b6f6735615f6d (diff) |
stdio: add support for "e" flag with fopen()
Support this useful glibc extension for optionally setting O_CLOEXEC
on fopen streams.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libc/stdio/_fopen.c')
-rw-r--r-- | libc/stdio/_fopen.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libc/stdio/_fopen.c b/libc/stdio/_fopen.c index 2db27a898..5bc61cf39 100644 --- a/libc/stdio/_fopen.c +++ b/libc/stdio/_fopen.c @@ -69,7 +69,8 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode, #warning CONSIDER: Implement glibc mmap option for readonly files? #warning CONSIDER: Implement a text mode using custom read/write funcs? #endif -#if defined(__UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__) || defined(__UCLIBC_HAS_FOPEN_LARGEFILE_MODE__) +#if defined(__UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__) || defined(__UCLIBC_HAS_FOPEN_LARGEFILE_MODE__) || \ + defined(__UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE__) while (*++mode) { # ifdef __UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__ @@ -84,6 +85,12 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode, continue; } # endif +# ifdef __UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE__ + if (*mode == 'e') { /* Close on exec (a glibc extension). */ + open_mode |= O_CLOEXEC; + continue; + } +# endif } #endif |