[Lldb-commits] [PATCH] D19136: Don't disable stdin and stdout buffering on Windows

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 14 16:11:22 PDT 2016

amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

Disabling buffering exposes a bug in the MS VS 2015 CRT implementation of fgets, where you sometimes have to hit Enter twice, depending on if the input had an odd or even number of characters.

This was hidden until a few days ago by the Python initialization which was re-enabling buffering on the streams.  A few days ago, Enrico make the Python initialization on-demand, which exposed this problem.



Index: tools/driver/Driver.cpp
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -1037,8 +1037,10 @@
         atexit (reset_stdin_termios);
+#ifndef _MSC_VER
     ::setbuf (stdin, NULL);
     ::setbuf (stdout, NULL);
     m_debugger.SetErrorFileHandle (stderr, false);
     m_debugger.SetOutputFileHandle (stdout, false);
@@ -1309,12 +1311,6 @@
 main(int argc, char const *argv[])
-#ifdef _MSC_VER
-	// disable buffering on windows
-	setvbuf(stdout, NULL, _IONBF, 0);
-	setvbuf(stdin , NULL, _IONBF, 0);
 #ifdef _WIN32
         // Convert wide arguments to UTF-8
         std::vector<std::string> argvStrings(argc);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19136.53800.patch
Type: text/x-patch
Size: 733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160414/df059a8c/attachment.bin>

More information about the lldb-commits mailing list