summaryrefslogtreecommitdiff
path: root/src/stdio/fopen.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-09-29 18:09:34 -0400
committerRich Felker <dalias@aerifal.cx>2012-09-29 18:09:34 -0400
commit8582a6e9f25dd7b87d72961f58008052a4cac473 (patch)
treee9ba3b3d490bc26d6d61040a77bd1c7dabfda74e /src/stdio/fopen.c
parentf2d08cf7558176af7ef36cf5b5213e676b02d7ac (diff)
downloadmusl-8582a6e9f25dd7b87d72961f58008052a4cac473.tar.gz
add 'e' modifier (close-on-exec) to fopen and fdopen
this feature will be in the next version of POSIX, and can be used internally immediately. there are many internal uses of fopen where close-on-exec is needed to fix bugs.
Diffstat (limited to 'src/stdio/fopen.c')
-rw-r--r--src/stdio/fopen.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c
index 560b77e4..03c10cd1 100644
--- a/src/stdio/fopen.c
+++ b/src/stdio/fopen.c
@@ -17,6 +17,7 @@ FILE *fopen(const char *restrict filename, const char *restrict mode)
else if (*mode == 'r') flags = O_RDONLY;
else flags = O_WRONLY;
if (strchr(mode, 'x')) flags |= O_EXCL;
+ if (strchr(mode, 'e')) flags |= O_CLOEXEC;
if (*mode != 'r') flags |= O_CREAT;
if (*mode == 'w') flags |= O_TRUNC;
if (*mode == 'a') flags |= O_APPEND;