From d396dc93a7b2e2f55eb6a34f04fe796769e9ecea Mon Sep 17 00:00:00 2001 From: Spencer Low Date: Mon, 11 May 2015 15:23:39 -0700 Subject: [PATCH] adb: win32: fix daemon acknowledgement The daemon failed to startup because main.cpp was changed from calling WriteFile() to android::base::WriteStringToFd(), the later which calls write() in the C Runtime which by default has stdout in textmode which does \n to \r\n translation. The quick fix is to change stdout's mode from text to binary since right after it is reopened to redirect to the daemon log file anyway. Change-Id: I322fc9eae5d6abbf63f3d5917b0beb2171b5a15c Signed-off-by: Spencer Low --- adb/client/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adb/client/main.cpp b/adb/client/main.cpp index 468909aef..f48182d07 100644 --- a/adb/client/main.cpp +++ b/adb/client/main.cpp @@ -156,6 +156,10 @@ int adb_main(int is_daemon, int server_port) { // TODO(danalbert): Why do we use stdout for Windows? #if defined(_WIN32) int reply_fd = STDOUT_FILENO; + // Change stdout mode to binary so \n => \r\n translation does not + // occur. In a moment stdout will be reopened to the daemon log file + // anyway. + _setmode(reply_fd, _O_BINARY); #else int reply_fd = STDERR_FILENO; #endif