summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao2018-05-22 19:01:29 -0500
committerGerrit Code Review2018-05-22 19:01:29 -0500
commit7a223584c5c72f7d16e6abc490125faa2349d98a (patch)
tree96942105aba10132fd8e68e517a153b35acbf747 /adb/adb_unique_fd.h
parent2a1c0dd6df7a2cc9817fe9d7fc8ae10a07c96564 (diff)
parent3b37fa256f00abc6a6414984cabbb3dd9e0a0ad1 (diff)
downloadplatform-system-core-7a223584c5c72f7d16e6abc490125faa2349d98a.tar.gz
platform-system-core-7a223584c5c72f7d16e6abc490125faa2349d98a.tar.xz
platform-system-core-7a223584c5c72f7d16e6abc490125faa2349d98a.zip
Merge changes I465804fd,Ib5a684bb,If5e66570,I8471cc00,I8ba0a70a
* changes: adb: convert fdevent over to unique_fd. adb: move towards using unique_fd. adb: delete FDEVENT_DONTCLOSE. adb: remove fdevent_install, fdevent_remove. adb: fix uninitialized variable in AsyncServiceRef.
Diffstat (limited to 'adb/adb_unique_fd.h')
-rw-r--r--adb/adb_unique_fd.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/adb/adb_unique_fd.h b/adb/adb_unique_fd.h
index 34c1bbcfa..9c02cbeec 100644
--- a/adb/adb_unique_fd.h
+++ b/adb/adb_unique_fd.h
@@ -16,6 +16,8 @@
16 16
17#pragma once 17#pragma once
18 18
19#include <unistd.h>
20
19#include <android-base/unique_fd.h> 21#include <android-base/unique_fd.h>
20 22
21// Helper to automatically close an FD when it goes out of scope. 23// Helper to automatically close an FD when it goes out of scope.
@@ -24,3 +26,15 @@ struct AdbCloser {
24}; 26};
25 27
26using unique_fd = android::base::unique_fd_impl<AdbCloser>; 28using unique_fd = android::base::unique_fd_impl<AdbCloser>;
29
30#if !defined(_WIN32)
31inline bool Pipe(unique_fd* read, unique_fd* write) {
32 int pipefd[2];
33 if (pipe(pipefd) != 0) {
34 return false;
35 }
36 read->reset(pipefd[0]);
37 write->reset(pipefd[1]);
38 return true;
39}
40#endif