From 4b019a5f25ab3a930e42f035bb5091152d34a8b5 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Thu, 7 Feb 2019 14:13:39 -0800 Subject: [PATCH] adb: "support" O_CLOEXEC in adb_open on Windows. Previously, we were rejecting the flag and failing with EINVAL. File handles aren't inherited by default, so just ignore the flag. Bug: http://b/123753498 Test: adb install --streaming foo.apk Change-Id: I17401fcdd58024956d47a5c4c0c57b06831d9817 --- adb/sysdeps_win32.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adb/sysdeps_win32.cpp b/adb/sysdeps_win32.cpp index d58758980..4c5d8cb64 100644 --- a/adb/sysdeps_win32.cpp +++ b/adb/sysdeps_win32.cpp @@ -356,6 +356,9 @@ int adb_open(const char* path, int options) { DWORD desiredAccess = 0; DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + // CreateFileW is inherently O_CLOEXEC by default. + options &= ~O_CLOEXEC; + switch (options) { case O_RDONLY: desiredAccess = GENERIC_READ;