summaryrefslogtreecommitdiff
path: root/debuggerd/debuggerd.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-02-19 18:13:02 -0800
committerJosh Gao <jmgao@google.com>2016-03-17 13:11:01 -0700
commit1a69e2811e940fc6a01c5b57d59f6f5e85b40373 (patch)
tree4cd5cbe3a97cd036dcc0187f382e9f90855e67a9 /debuggerd/debuggerd.cpp
parentaa4175685157c59c1f88e2f7a7ee651e53932b49 (diff)
Clean up CLOEXEC in debuggerd.
Change-Id: I1cd75f6a8f98e99f4a4fedfc706103ce34035765 (cherry picked from commit 17ba68d0cde001c2e73a310ee9a895a5b3bb5d32)
Diffstat (limited to 'debuggerd/debuggerd.cpp')
-rw-r--r--debuggerd/debuggerd.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp
index c78698ae3..eabbb9abf 100644
--- a/debuggerd/debuggerd.cpp
+++ b/debuggerd/debuggerd.cpp
@@ -710,10 +710,9 @@ static int do_server() {
act.sa_flags = SA_NOCLDWAIT;
sigaction(SIGCHLD, &act, 0);
- int s = socket_local_server(SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
- if (s < 0)
- return 1;
- fcntl(s, F_SETFD, FD_CLOEXEC);
+ int s = socket_local_server(SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT,
+ SOCK_STREAM | SOCK_CLOEXEC);
+ if (s == -1) return 1;
ALOGI("debuggerd: starting\n");
@@ -723,14 +722,12 @@ static int do_server() {
socklen_t alen = sizeof(ss);
ALOGV("waiting for connection\n");
- int fd = accept(s, addrp, &alen);
- if (fd < 0) {
- ALOGV("accept failed: %s\n", strerror(errno));
+ int fd = accept4(s, addrp, &alen, SOCK_CLOEXEC);
+ if (fd == -1) {
+ ALOGE("accept failed: %s\n", strerror(errno));
continue;
}
- fcntl(fd, F_SETFD, FD_CLOEXEC);
-
handle_request(fd);
}
return 0;