summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorJosh Gao2018-06-01 17:47:20 -0500
committerJosh Gao2018-07-18 20:11:46 -0500
commitc954ec09c527ae1ad758ddd44b178da66c4c35e0 (patch)
tree842dead3542e166d4039984029d5d30912f9ff28 /base
parentfcf2c01b5599a96b968afb1528c996d9486937b0 (diff)
downloadplatform-system-core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.tar.gz
platform-system-core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.tar.xz
platform-system-core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.zip
debuggerd_handler: use syscall(__NR_close) instead of close.
Avoid bionic's file descriptor ownership checks by calling the close syscall manually. Test: debuggerd_test Change-Id: I10af6aca0e66fe030fd7a53506ae61c87695641d
Diffstat (limited to 'base')
-rw-r--r--base/include/android-base/unique_fd.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/base/include/android-base/unique_fd.h b/base/include/android-base/unique_fd.h
index 057f462e5..019d337c4 100644
--- a/base/include/android-base/unique_fd.h
+++ b/base/include/android-base/unique_fd.h
@@ -151,7 +151,8 @@ using unique_fd = unique_fd_impl<DefaultCloser>;
151#if !defined(_WIN32) 151#if !defined(_WIN32)
152 152
153// Inline functions, so that they can be used header-only. 153// Inline functions, so that they can be used header-only.
154inline bool Pipe(unique_fd* read, unique_fd* write) { 154template <typename Closer>
155inline bool Pipe(unique_fd_impl<Closer>* read, unique_fd_impl<Closer>* write) {
155 int pipefd[2]; 156 int pipefd[2];
156 157
157#if defined(__linux__) 158#if defined(__linux__)
@@ -175,7 +176,9 @@ inline bool Pipe(unique_fd* read, unique_fd* write) {
175 return true; 176 return true;
176} 177}
177 178
178inline bool Socketpair(int domain, int type, int protocol, unique_fd* left, unique_fd* right) { 179template <typename Closer>
180inline bool Socketpair(int domain, int type, int protocol, unique_fd_impl<Closer>* left,
181 unique_fd_impl<Closer>* right) {
179 int sockfd[2]; 182 int sockfd[2];
180 if (socketpair(domain, type, protocol, sockfd) != 0) { 183 if (socketpair(domain, type, protocol, sockfd) != 0) {
181 return false; 184 return false;
@@ -185,7 +188,8 @@ inline bool Socketpair(int domain, int type, int protocol, unique_fd* left, uniq
185 return true; 188 return true;
186} 189}
187 190
188inline bool Socketpair(int type, unique_fd* left, unique_fd* right) { 191template <typename Closer>
192inline bool Socketpair(int type, unique_fd_impl<Closer>* left, unique_fd_impl<Closer>* right) {
189 return Socketpair(AF_UNIX, type, 0, left, right); 193 return Socketpair(AF_UNIX, type, 0, left, right);
190} 194}
191 195