summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/select.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/select.cc
parentbb25dd1b0f39f343b764fd0db861cb9a30441407 (diff)
downloadcygnal-434e42efbbf0cb5a4da65c58a11ca712fd0ae8b6.tar.gz
cygnal-434e42efbbf0cb5a4da65c58a11ca712fd0ae8b6.tar.bz2
cygnal-434e42efbbf0cb5a4da65c58a11ca712fd0ae8b6.zip
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/select.cc')
-rw-r--r--winsup/cygwin/select.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index b06441c77..f3e3e4482 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -1075,19 +1075,49 @@ verify_console (select_record *me, fd_set *rfds, fd_set *wfds,
return peek_console (me, true);
}
+static int
+console_startup (select_record *me, select_stuff *stuff)
+{
+ select_record *s = stuff->start.next;
+ if (wincap.has_con_24bit_colors ())
+ {
+ DWORD dwMode;
+ GetConsoleMode (s->h, &dwMode);
+ /* Enable xterm compatible mode in input */
+ dwMode |= ENABLE_VIRTUAL_TERMINAL_INPUT;
+ SetConsoleMode (s->h, dwMode);
+ }
+ return 1;
+}
+
+static void
+console_cleanup (select_record *me, select_stuff *stuff)
+{
+ select_record *s = stuff->start.next;
+ if (wincap.has_con_24bit_colors ())
+ {
+ DWORD dwMode;
+ GetConsoleMode (s->h, &dwMode);
+ /* Disable xterm compatible mode in input */
+ dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT;
+ SetConsoleMode (s->h, dwMode);
+ }
+}
+
select_record *
fhandler_console::select_read (select_stuff *ss)
{
select_record *s = ss->start.next;
if (!s->startup)
{
- s->startup = no_startup;
+ s->startup = console_startup;
s->verify = verify_console;
set_cursor_maybe ();
}
s->peek = peek_console;
s->h = get_handle ();
+ s->cleanup = console_cleanup;
s->read_selected = true;
s->read_ready = input_ready || get_cons_readahead_valid ();
return s;