summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fdopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/fdopen.c')
-rw-r--r--lib/libc/stdio/fdopen.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c
index 26e2cd7..8fc90a4 100644
--- a/lib/libc/stdio/fdopen.c
+++ b/lib/libc/stdio/fdopen.c
@@ -80,6 +80,12 @@ fdopen(fd, mode)
if ((fp = __sfp()) == NULL)
return (NULL);
+
+ if ((oflags & O_CLOEXEC) && _fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
+ fp->_flags = 0;
+ return (NULL);
+ }
+
fp->_flags = flags;
/*
* If opened for appending, but underlying descriptor does not have
OpenPOWER on IntegriCloud