diff options
Diffstat (limited to 'lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp')
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp b/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp index 7f846a86c2e..0fd749772ff 100644 --- a/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp +++ b/lldb/tools/lldb-mi/MICmnStreamStdinLinux.cpp @@ -22,7 +22,9 @@ // Third Party Headers: #if !defined(_MSC_VER) #include <sys/select.h> +#include <unistd.h> #include <termios.h> +#include <sys/ioctl.h> #endif // !defined( _MSC_VER ) #include <string.h> // For std::strerror() @@ -153,30 +155,29 @@ CMICmnStreamStdinLinux::Shutdown(void) bool CMICmnStreamStdinLinux::InputAvailable(bool &vwbAvail) { - /* AD: Not used ATM but could come in handy just in case we need to do - this, poll for input - - static const int STDIN = 0; - static bool bInitialized = false; - - if( !bInitialized ) - { - // Use termios to turn off line buffering - ::termios term; - ::tcgetattr( STDIN, &term ); - ::term.c_lflag &= ~ICANON; - ::tcsetattr( STDIN, TCSANOW, &term ); - ::setbuf( stdin, NULL ); - bInitialized = true; - } - - int nBytesWaiting; - ::ioctl( STDIN, FIONREAD, &nBytesWaiting ); - vwbAvail = (nBytesWaiting > 0); - - return MIstatus::success; - */ +#if !defined(_WIN32) + // The code below is needed on OSX where lldb-mi hangs when doing -exec-run. + // The hang seems to come from calling fgets and fileno from different thread. + // Although this problem was not observed on Linux. + // A solution based on 'select' was also proposed but it seems to slow things down + // a lot. + static bool bInitialized = false; + + if (!bInitialized) + { + // Use termios to turn off line buffering + ::termios term; + ::tcgetattr(STDIN_FILENO, &term); + term.c_lflag &= ~ICANON; + ::tcsetattr(STDIN_FILENO, TCSANOW, &term); + ::setbuf(stdin, NULL); + bInitialized = true; + } + int nBytesWaiting; + ::ioctl(STDIN_FILENO, FIONREAD, &nBytesWaiting); + vwbAvail = (nBytesWaiting > 0); +#endif return MIstatus::success; } @@ -213,3 +214,16 @@ CMICmnStreamStdinLinux::ReadLine(CMIUtilString &vwErrMsg) return pText; } + +//++ ------------------------------------------------------------------------------------ +// Details: Interrupt current and prevent new ReadLine operations. +// Type: Method. +// Args: None. +// Return: None. +// Throws: None. +//-- +void +CMICmnStreamStdinLinux::InterruptReadLine(void) +{ + fclose(stdin); +} |

