From 8ba67072d5391286ee1a81cd01785f7f84e1001c Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Sat, 24 Aug 2019 23:19:45 +0200 Subject: [PATCH 1/2] Process: Unix: ensure we reconfigure the terminal for Console usage if only one of stdin/stdout was used by the child. Console: Unix: Fix cache check for VTIME (read timeout). Fixes https://github.com/dotnet/corefx/issues/40557 --- src/Native/Unix/System.Native/pal_console.c | 2 +- .../src/System/Diagnostics/Process.Unix.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Native/Unix/System.Native/pal_console.c b/src/Native/Unix/System.Native/pal_console.c index f59d5e70cb2e..e2f15174001f 100644 --- a/src/Native/Unix/System.Native/pal_console.c +++ b/src/Native/Unix/System.Native/pal_console.c @@ -192,7 +192,7 @@ static bool ConfigureTerminal(bool signalForBreak, bool forChild, uint8_t minCha if (g_currentTermios.c_lflag == termios.c_lflag && g_currentTermios.c_iflag == termios.c_iflag && g_currentTermios.c_cc[VMIN] == termios.c_cc[VMIN] && - g_currentTermios.c_cc[VMIN] == termios.c_cc[VMIN]) + g_currentTermios.c_cc[VTIME] == termios.c_cc[VTIME]) { return true; } diff --git a/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs b/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs index 10762644e4bf..3ecb026e6933 100644 --- a/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs +++ b/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs @@ -398,8 +398,7 @@ private bool StartCore(ProcessStartInfo startInfo) // Unix applications expect the terminal to be in an echoing state by default. // To support processes that interact with the terminal (e.g. 'vi'), we need to configure the // terminal to echo. We keep this configuration as long as there are children possibly using the terminal. - // We consider the child to be interactively using the terminal when both stdin and stdout are connected. - bool usesTerminal = !startInfo.RedirectStandardInput && !startInfo.RedirectStandardOutput; + bool usesTerminal = !startInfo.RedirectStandardInput || !startInfo.RedirectStandardOutput; if (startInfo.UseShellExecute) { From 1cb31eb482c354c61df559583db61571f4a267f5 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Mon, 26 Aug 2019 17:18:16 +0200 Subject: [PATCH 2/2] Also consider not redirecting stderr as terminal usage --- .../src/System/Diagnostics/Process.Unix.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs b/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs index 3ecb026e6933..26b486b60366 100644 --- a/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs +++ b/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs @@ -398,7 +398,9 @@ private bool StartCore(ProcessStartInfo startInfo) // Unix applications expect the terminal to be in an echoing state by default. // To support processes that interact with the terminal (e.g. 'vi'), we need to configure the // terminal to echo. We keep this configuration as long as there are children possibly using the terminal. - bool usesTerminal = !startInfo.RedirectStandardInput || !startInfo.RedirectStandardOutput; + bool usesTerminal = !(startInfo.RedirectStandardInput && + startInfo.RedirectStandardOutput && + startInfo.RedirectStandardError); if (startInfo.UseShellExecute) {