static bool g_reading = false; // tracks whether the application is performing a Console.Read operation
static bool g_childUsesTerminal = false; // tracks whether a child process is using the terminal
static bool g_terminalUninitialized = false; // tracks whether the application is terminating
+static bool g_terminalConfigured = false; // tracks whether the application configured the terminal.
static bool g_hasTty = false; // cache we are not a tty
// On success, update the cached value.
if (rv)
{
+ g_terminalConfigured = true;
g_hasCurrentTermios = true;
g_currentTermios = *termios;
}
{
if (!g_terminalUninitialized)
{
- TcSetAttr(&g_initTermios, /* blockIfBackground */ false);
+ // Avoid configuring the terminal: only reset terminal settings when our process has changed them.
+ if (g_terminalConfigured)
+ {
+ TcSetAttr(&g_initTermios, /* blockIfBackground */ false);
+ }
g_terminalUninitialized = true;
}
g_hasCurrentTermios = false;
}
- ConfigureTerminal(g_signalForBreak, /* forChild */ childUsesTerminal, /* minChars */ 1, /* decisecondsTimeout */ 0, /* blockIfBackground */ false);
+ // Avoid configuring the terminal: only change terminal settings when our process has changed them.
+ if (g_terminalConfigured)
+ {
+ ConfigureTerminal(g_signalForBreak, /* forChild */ childUsesTerminal, /* minChars */ 1, /* decisecondsTimeout */ 0, /* blockIfBackground */ false);
+ }
// Redo "Application mode" when there are no more children using the terminal.
if (!childUsesTerminal)