diff options
-rw-r--r-- | adb/adb_unique_fd.h | 9 |
1 files 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 @@ | |||
16 | 16 | ||
17 | #pragma once | 17 | #pragma once |
18 | 18 | ||
19 | #include <errno.h> | ||
19 | #include <unistd.h> | 20 | #include <unistd.h> |
20 | 21 | ||
21 | #include <android-base/unique_fd.h> | 22 | #include <android-base/unique_fd.h> |
@@ -48,14 +49,18 @@ inline bool Pipe(unique_fd* read, unique_fd* write, int flags = 0) { | |||
48 | if (flags & O_CLOEXEC) { | 49 | if (flags & O_CLOEXEC) { |
49 | if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) != 0 || | 50 | if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) != 0 || |
50 | fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) != 0) { | 51 | fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) != 0) { |
51 | PLOG(FATAL) << "failed to set FD_CLOEXEC on newly created pipe"; | 52 | close(pipefd[0]); |
53 | close(pipefd[1]); | ||
54 | return false; | ||
52 | } | 55 | } |
53 | } | 56 | } |
54 | 57 | ||
55 | if (flags & O_NONBLOCK) { | 58 | if (flags & O_NONBLOCK) { |
56 | if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) != 0 || | 59 | if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) != 0 || |
57 | fcntl(pipefd[1], F_SETFL, O_NONBLOCK) != 0) { | 60 | fcntl(pipefd[1], F_SETFL, O_NONBLOCK) != 0) { |
58 | PLOG(FATAL) << "failed to set O_NONBLOCK on newly created pipe"; | 61 | close(pipefd[0]); |
62 | close(pipefd[1]); | ||
63 | return false; | ||
59 | } | 64 | } |
60 | } | 65 | } |
61 | #endif | 66 | #endif |