summaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-03-25 11:18:36 -0700
committerElliott Hughes <enh@google.com>2019-03-25 11:18:36 -0700
commit137b6f36ef5fea86e5b672188323e87dc0d66781 (patch)
tree2d44b9b1e095133b39e1ad4f51a9622cdef0d101 /libc/stdio/stdio.cpp
parente187d92062b3a384f8c4730f93aa6c36e1c74b52 (diff)
popen: stop using _fwalk.
We don't need this now that popen always uses O_CLOEXEC, and it's unsafe because _fwalk takes a lock. (In <= P, the equivalent code walked the list without a lock in the child.) Bug: http://b/129156634 Test: ran tests Change-Id: Ic9cee7eb59cfc9397f370d1dc47ea3d3326179ca
Diffstat (limited to 'libc/stdio/stdio.cpp')
-rw-r--r--libc/stdio/stdio.cpp8
1 files changed, 0 insertions, 8 deletions
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index d7b69dcb5..8144e5f1d 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -1169,11 +1169,6 @@ size_t fwrite_unlocked(const void* buf, size_t size, size_t count, FILE* fp) {
return (__sfvwrite(fp, &uio) == 0) ? count : ((n - uio.uio_resid) / size);
}
-static int __close_if_popened(FILE* fp) {
- if (_EXT(fp)->_popen_pid > 0) close(fileno(fp));
- return 0;
-}
-
static FILE* __popen_fail(int fds[2]) {
ErrnoRestorer errno_restorer;
close(fds[0]);
@@ -1219,9 +1214,6 @@ FILE* popen(const char* cmd, const char* mode) {
if (pid == 0) {
close(fds[parent]);
- // 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."
- _fwalk(__close_if_popened);
// dup2 so that the child fd isn't closed on exec.
if (dup2(fds[child], desired_child_fd) == -1) _exit(127);
close(fds[child]);