summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2018-06-01 15:47:20 -0700
committerJosh Gao <jmgao@google.com>2018-07-18 18:11:46 -0700
commitc954ec09c527ae1ad758ddd44b178da66c4c35e0 (patch)
tree842dead3542e166d4039984029d5d30912f9ff28 /base
parentfcf2c01b5599a96b968afb1528c996d9486937b0 (diff)
downloadsystem_core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.tar.gz
system_core-c954ec09c527ae1ad758ddd44b178da66c4c35e0.tar.bz2
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>;
#if !defined(_WIN32)
// Inline functions, so that they can be used header-only.
-inline bool Pipe(unique_fd* read, unique_fd* write) {
+template <typename Closer>
+inline bool Pipe(unique_fd_impl<Closer>* read, unique_fd_impl<Closer>* write) {
int pipefd[2];
#if defined(__linux__)
@@ -175,7 +176,9 @@ inline bool Pipe(unique_fd* read, unique_fd* write) {
return true;
}
-inline bool Socketpair(int domain, int type, int protocol, unique_fd* left, unique_fd* right) {
+template <typename Closer>
+inline bool Socketpair(int domain, int type, int protocol, unique_fd_impl<Closer>* left,
+ unique_fd_impl<Closer>* right) {
int sockfd[2];
if (socketpair(domain, type, protocol, sockfd) != 0) {
return false;
@@ -185,7 +188,8 @@ inline bool Socketpair(int domain, int type, int protocol, unique_fd* left, uniq
return true;
}
-inline bool Socketpair(int type, unique_fd* left, unique_fd* right) {
+template <typename Closer>
+inline bool Socketpair(int type, unique_fd_impl<Closer>* left, unique_fd_impl<Closer>* right) {
return Socketpair(AF_UNIX, type, 0, left, right);
}