Skip to content

Commit ef69223

Browse files
tyan0dscho
authored andcommitted
Cygwin: console: Call set_input_mode() after changing disable_master_thread
With the commit 476135a24506, set_input_mode() reffers to the flag disable_master_thread in tty::cygwin mode. So it is necessary to call set_input_mode() after changing disable_master_thread flag. However, the commit 476135a24506 was missing that. With this patch, set_input_mode() is called after changing the flag disable_master_thread, if the console input mode is tty::cygwin. Fixes: 476135a24506 ("Cygwin: console: Set ENABLE_PROCESSED_INPUT when disable_master_thread"); Signed-off-by: Takashi Yano <[email protected]> Cherry-picked-from: 65a48c7202 (Cygwin: console: Call set_input_mode() after changing disable_master_thread, 2025-07-03) Signed-off-by: Johannes Schindelin <[email protected]>
1 parent c2ff7fc commit ef69223

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

winsup/cygwin/fhandler/console.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,12 +923,12 @@ fhandler_console::cleanup_for_non_cygwin_app (handle_set_t *p)
923923
termios *ti = shared_console_info[unit] ?
924924
&(shared_console_info[unit]->tty_min_state.ti) : &dummy;
925925
/* Cleaning-up console mode for non-cygwin app. */
926+
set_disable_master_thread (con.owner == GetCurrentProcessId ());
926927
/* conmode can be tty::restore when non-cygwin app is
927928
exec'ed from login shell. */
928929
tty::cons_mode conmode = cons_mode_on_close (p);
929930
set_output_mode (conmode, ti, p);
930931
set_input_mode (conmode, ti, p);
931-
set_disable_master_thread (con.owner == GetCurrentProcessId ());
932932
}
933933

934934
/* Return the tty structure associated with a given tty number. If the
@@ -1121,8 +1121,8 @@ fhandler_console::bg_check (int sig, bool dontsignal)
11211121
in the same process group. */
11221122
if (sig == SIGTTIN && con.curr_input_mode != tty::cygwin)
11231123
{
1124-
set_input_mode (tty::cygwin, &tc ()->ti, get_handle_set ());
11251124
set_disable_master_thread (false, this);
1125+
set_input_mode (tty::cygwin, &tc ()->ti, get_handle_set ());
11261126
}
11271127
if (sig == SIGTTOU && con.curr_output_mode != tty::cygwin)
11281128
set_output_mode (tty::cygwin, &tc ()->ti, get_handle_set ());
@@ -1987,8 +1987,8 @@ fhandler_console::post_open_setup (int fd)
19871987
/* Setting-up console mode for cygwin app started from non-cygwin app. */
19881988
if (fd == 0)
19891989
{
1990-
set_input_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
19911990
set_disable_master_thread (false, this);
1991+
set_input_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
19921992
}
19931993
else if (fd == 1 || fd == 2)
19941994
set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
@@ -2995,7 +2995,12 @@ fhandler_console::char_command (char c)
29952995
if (con.args[i] == 1) /* DECCKM */
29962996
con.cursor_key_app_mode = (c == 'h');
29972997
if (con.args[i] == 9001) /* win32-input-mode (https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md) */
2998-
set_disable_master_thread (c == 'h', this);
2998+
{
2999+
set_disable_master_thread (c == 'h', this);
3000+
if (con.curr_input_mode == tty::cygwin)
3001+
set_input_mode (tty::cygwin,
3002+
&tc ()->ti, get_handle_set ());
3003+
}
29993004
}
30003005
/* Call fix_tab_position() if screen has been alternated. */
30013006
if (need_fix_tab_position)

0 commit comments

Comments
 (0)