Merge "popen: stop using _fwalk."

am: 49e7b68ac2

Change-Id: I5c1cf191d1156e03b46e64dadbd464844946f9af
This commit is contained in:
Elliott Hughes 2019-03-25 16:58:28 -07:00 committed by android-build-merger
commit db64bbbb6e

View file

@ -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); 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]) { static FILE* __popen_fail(int fds[2]) {
ErrnoRestorer errno_restorer; ErrnoRestorer errno_restorer;
close(fds[0]); close(fds[0]);
@ -1219,9 +1214,6 @@ FILE* popen(const char* cmd, const char* mode) {
if (pid == 0) { if (pid == 0) {
close(fds[parent]); 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. // dup2 so that the child fd isn't closed on exec.
if (dup2(fds[child], desired_child_fd) == -1) _exit(127); if (dup2(fds[child], desired_child_fd) == -1) _exit(127);
close(fds[child]); close(fds[child]);