Merge "macOS build fix: no SOCK_CLOEXEC on darwin." am: 8fbb0d8de0

Change-Id: Ia6e3030492ce8d017c58a4d6f77a1496fab92343
This commit is contained in:
Treehugger Robot 2020-04-15 23:40:20 +00:00 committed by Automerger Merge Worker
commit c933da92d6

View file

@ -122,7 +122,16 @@ AdbConnectionClientContext* adbconnection_client_new(
return nullptr;
}
#if defined(__APPLE__)
ctx->control_socket_.reset(socket(AF_UNIX, SOCK_SEQPACKET, 0));
// TODO: find a better home for all these copies of the mac CLOEXEC workaround.
if (int fd = ctx->control_socket_.get(), flags = fcntl(fd, F_GETFD);
flags != -1 && (flags & FD_CLOEXEC) == 0) {
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
}
#else
ctx->control_socket_.reset(socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0));
#endif
if (ctx->control_socket_ < 0) {
PLOG(ERROR) << "failed to create Unix domain socket";
return nullptr;