Merge "base: hopefully fix the mac build." am: 815f74a759

am: 8949a0255e

Change-Id: I97a5cc9e916ea0905861a2bd87c6902cdc66187c
This commit is contained in:
Josh Gao 2017-08-30 08:14:27 +00:00 committed by android-build-merger
commit 35e06ef181

View file

@ -100,9 +100,23 @@ using unique_fd = unique_fd_impl<DefaultCloser>;
// Inline functions, so that they can be used header-only. // Inline functions, so that they can be used header-only.
inline bool Pipe(unique_fd* read, unique_fd* write) { inline bool Pipe(unique_fd* read, unique_fd* write) {
int pipefd[2]; int pipefd[2];
#if defined(__linux__)
if (pipe2(pipefd, O_CLOEXEC) != 0) { if (pipe2(pipefd, O_CLOEXEC) != 0) {
return false; return false;
} }
#else // defined(__APPLE__)
if (pipe(pipefd) != 0) {
return false;
}
if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) != 0 || fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) != 0) {
close(pipefd[0]);
close(pipefd[1]);
return false;
}
#endif
read->reset(pipefd[0]); read->reset(pipefd[0]);
write->reset(pipefd[1]); write->reset(pipefd[1]);
return true; return true;