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 <CompareAndSwap@gmail.com>
This commit is contained in:
Spencer Low 2015-05-11 15:23:39 -07:00
parent 85abaf66c4
commit d396dc93a7

View file

@ -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