Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12f0dfc9 authored by Josh Gao's avatar Josh Gao Committed by android-build-merger
Browse files

Merge "base: hopefully fix the mac build." am: 815f74a7 am: 8949a025

am: 35e06ef1

Change-Id: Ib9202c26a95e3d264bd0ad0bf215ad257e5b5764
parents 9cd73e43 35e06ef1
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -100,9 +100,23 @@ using unique_fd = unique_fd_impl<DefaultCloser>;
// Inline functions, so that they can be used header-only.
inline bool Pipe(unique_fd* read, unique_fd* write) {
  int pipefd[2];

#if defined(__linux__)
  if (pipe2(pipefd, O_CLOEXEC) != 0) {
    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]);
  write->reset(pipefd[1]);
  return true;