From 0edaf42d100053ed35051c0281f039572007d16a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 21 Jan 2019 20:29:31 -0600 Subject: [PATCH] Fix regression for #4178 and others introduced by 364c839 ...while still keeping intact the fix for #5519. --- src/reader.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 78e930f63..b2c241952 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2492,8 +2492,16 @@ const wchar_t *reader_readline(int nchars) { if (tcgetattr(STDIN_FILENO, &old_modes) == -1 && errno == EIO) redirect_tty_output(); // Set the new modes. if (tcsetattr(0, TCSANOW, &shell_modes) == -1) { - if (errno == EIO) redirect_tty_output(); - wperror(L"tcsetattr"); + int err = errno; + if (err == EIO) { + redirect_tty_output(); + } + // This check is required to work around certain issues with fish's approach to + // terminal control when launching interactive processes while in non-interactive + // mode. See #4178 for one such example. + if (err != ENOTTY || is_interactive_session) { + wperror(L"tcsetattr"); + } } while (!finished && !data->end_loop) {