Pass SOCK_CLOEXEC to adb socket.
We were not passing CLOEXEC to the adb-socket in adbconnection. This
could lead to extra (unusable) jdwp PIDs in adb jdwp in some
circumstances.
Test: Build an app with wrap.sh.
adb jdwp on a userdebug device.
Ensure pid of wrap.sh is not present in list.
Bug: 109505014
Change-Id: Icd41bf037666d6abe35897681aed98b00fb290ac
diff --git a/adbconnection/adbconnection.cc b/adbconnection/adbconnection.cc
index 8cd0d8b..d399c2a 100644
--- a/adbconnection/adbconnection.cc
+++ b/adbconnection/adbconnection.cc
@@ -489,7 +489,7 @@
int sleep_ms = 500;
const int sleep_max_ms = 2*1000;
- android::base::unique_fd sock(socket(AF_UNIX, SOCK_SEQPACKET, 0));
+ android::base::unique_fd sock(socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0));
if (sock < 0) {
PLOG(ERROR) << "Could not create ADB control socket";
return false;