From 99c27d3e99cb9524b63f02c3c4b1204daa5929d9 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Thu, 24 May 2018 00:47:05 -0700 Subject: [PATCH] adb: fix mac build. Test: none Change-Id: I93ff87338aa503588e36404f7566651e18f50292 --- adb/adb_unique_fd.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/adb/adb_unique_fd.h b/adb/adb_unique_fd.h index 7d2354d0e..d1dc9d10e 100644 --- a/adb/adb_unique_fd.h +++ b/adb/adb_unique_fd.h @@ -16,6 +16,7 @@ #pragma once +#include #include #include @@ -48,14 +49,18 @@ inline bool Pipe(unique_fd* read, unique_fd* write, int flags = 0) { if (flags & O_CLOEXEC) { if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) != 0 || fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) != 0) { - PLOG(FATAL) << "failed to set FD_CLOEXEC on newly created pipe"; + close(pipefd[0]); + close(pipefd[1]); + return false; } } if (flags & O_NONBLOCK) { if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) != 0 || fcntl(pipefd[1], F_SETFL, O_NONBLOCK) != 0) { - PLOG(FATAL) << "failed to set O_NONBLOCK on newly created pipe"; + close(pipefd[0]); + close(pipefd[1]); + return false; } } #endif