[Lldb-commits] [lldb] r149577 - /lldb/tags/lldb-111/tools/driver/Driver.cpp
Greg Clayton
gclayton at apple.com
Wed Feb 1 17:12:04 PST 2012
Author: gclayton
Date: Wed Feb 1 19:12:04 2012
New Revision: 149577
URL: http://llvm.org/viewvc/llvm-project?rev=149577&view=rev
Log:
<rdar://problem/10792655>
Don't hose bash terminal settings when exiting LLDB. This only happened in
bash (csh and tcsh weren't affected).
Modified:
lldb/tags/lldb-111/tools/driver/Driver.cpp
Modified: lldb/tags/lldb-111/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-111/tools/driver/Driver.cpp?rev=149577&r1=149576&r2=149577&view=diff
==============================================================================
--- lldb/tags/lldb-111/tools/driver/Driver.cpp (original)
+++ lldb/tags/lldb-111/tools/driver/Driver.cpp Wed Feb 1 19:12:04 2012
@@ -37,6 +37,7 @@
using namespace lldb;
static void reset_stdin_termios ();
+static bool g_old_stdin_termios_is_valid = false;
static struct termios g_old_stdin_termios;
static char *g_debugger_name = (char *) "";
@@ -47,7 +48,11 @@
static void
reset_stdin_termios ()
{
- ::tcsetattr (STDIN_FILENO, TCSANOW, &g_old_stdin_termios);
+ if (g_old_stdin_termios_is_valid)
+ {
+ g_old_stdin_termios_is_valid = false;
+ ::tcsetattr (STDIN_FILENO, TCSANOW, &g_old_stdin_termios);
+ }
}
typedef struct
@@ -1109,7 +1114,10 @@
// struct termios stdin_termios;
if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0)
+ {
+ g_old_stdin_termios_is_valid = true;
atexit (reset_stdin_termios);
+ }
::setbuf (stdin, NULL);
::setbuf (stdout, NULL);
@@ -1348,10 +1356,6 @@
{
if (event_type & SBCommandInterpreter::eBroadcastBitQuitCommandReceived)
{
- editline_output_pty.CloseMasterFileDescriptor();
- master_out_comm.Disconnect();
- out_comm_2.Disconnect();
- fclose (stdin);
done = true;
}
else if (event_type & SBCommandInterpreter::eBroadcastBitAsynchronousErrorData)
@@ -1369,7 +1373,11 @@
}
}
- reset_stdin_termios ();
+ editline_output_pty.CloseMasterFileDescriptor();
+ master_out_comm.Disconnect();
+ out_comm_2.Disconnect();
+ reset_stdin_termios();
+ fclose (stdin);
CloseIOChannelFile ();
More information about the lldb-commits
mailing list