summaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-08-03 15:54:18 -0700
committerElliott Hughes <enh@google.com>2018-08-03 15:54:18 -0700
commit9b6fefd89bfdad7bbce10264754dac701c664414 (patch)
tree1519b2b2186964c44f9122e0c45c0950cb3a851f /libc/stdio/stdio.cpp
parentb0c8a01de1dafc1e47f74895d00ca82429f851b3 (diff)
Make all popen(3) file descriptors O_CLOEXEC.
POSIX says "The popen() function shall ensure that any streams from previous popen() calls that remain open in the parent process are closed in the new child process". It doesn't appear to disallow all popen(3) file descriptors from being O_CLOEXEC, and it's not obvious why anyone would want them inherited. Let's see if we can make the stricter guarantee... Bug: N/A Test: ran tests Change-Id: I2c85170d730b211637afb8ba10df150ca3237262
Diffstat (limited to 'libc/stdio/stdio.cpp')
-rw-r--r--libc/stdio/stdio.cpp4
1 files changed, 0 insertions, 4 deletions
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 050157bda..71fdd273e 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -1178,8 +1178,6 @@ static FILE* __popen_fail(int fds[2]) {
}
FILE* popen(const char* cmd, const char* mode) {
- bool close_on_exec = (strchr(mode, 'e') != nullptr);
-
// Was the request for a socketpair or just a pipe?
int fds[2];
bool bidirectional = false;
@@ -1231,8 +1229,6 @@ FILE* popen(const char* cmd, const char* mode) {
FILE* fp = fdopen(fds[parent], mode);
if (fp == nullptr) return __popen_fail(fds);
- // The caller didn't ask for their pipe to be O_CLOEXEC, so flip it back now the child has forked.
- if (!close_on_exec) fcntl(fds[parent], F_SETFD, 0);
close(fds[child]);
_EXT(fp)->_popen_pid = pid;