aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2020-02-17 19:29:07 +0900
committerCorinna Vinschen <corinna@vinschen.de>2020-02-17 13:21:11 +0100
commit774b8996d1f3e535e8267be4eb8e751d756c2cec (patch)
treed4fc5e735ae5dc468bd33b81f7794c4ba50aa0ed /winsup/cygwin/spawn.cc
parentbb25dd1b0f39f343b764fd0db861cb9a30441407 (diff)
downloadnewlib-774b8996d1f3e535e8267be4eb8e751d756c2cec.zip
newlib-774b8996d1f3e535e8267be4eb8e751d756c2cec.tar.gz
newlib-774b8996d1f3e535e8267be4eb8e751d756c2cec.tar.bz2
Cygwin: console: Change timing of set/unset xterm compatible mode.cygwin-3_1_3-release
- If two cygwin programs are executed simultaneousley with pipes in cmd.exe, xterm compatible mode is accidentally disabled by the process which ends first. After that, escape sequences are not handled correctly in the other app. This is the problem 2 reported in https://cygwin.com/ml/cygwin/2020-02/msg00116.html. This patch fixes the issue. This patch also fixes the problem 3. For these issues, the timing of setting and unsetting xterm compatible mode is changed. For read, xterm compatible mode is enabled only within read() or select() functions. For write, it is enabled every time write() is called, and restored on close().
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc23
1 files changed, 7 insertions, 16 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index f7c6dd5..772fe6d 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -615,22 +615,13 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
{
attach_to_console = true;
if (wincap.has_con_24bit_colors () && !iscygwin ())
- {
- DWORD dwMode;
- if (fd == 0)
- {
- /* Disable xterm compatible mode in input */
- GetConsoleMode (fh->get_handle (), &dwMode);
- dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT;
- SetConsoleMode (fh->get_handle (), dwMode);
- }
- else
- {
- GetConsoleMode (fh->get_output_handle (), &dwMode);
- dwMode &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING;
- SetConsoleMode (fh->get_output_handle (), dwMode);
- }
- }
+ if (fd == 1 || fd == 2)
+ {
+ DWORD dwMode;
+ GetConsoleMode (fh->get_output_handle (), &dwMode);
+ dwMode &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+ SetConsoleMode (fh->get_output_handle (), dwMode);
+ }
}
}