Skip to content

Commit 0e7838e

Browse files
committed
Revert "Cygwin: console: Store console mode only when console is opened"
Unfortunately, reverting d9ebf01 (Cygwin: console: Fix tcsetattr which was broken sinse cygwin 3.5.5, 2025-04-08) is not enough to reinstate Ctrl+C behavior during clones via SSH in Git for Windows, it is also necessary to revert c94808b (Cygwin: console: Store console mode only when console is opened, 2025-05-07). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent a5073eb commit 0e7838e

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

winsup/cygwin/fhandler/console.cc

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,6 @@ fhandler_console::setup ()
771771
con.disable_master_thread = true;
772772
con.master_thread_suspended = false;
773773
con.num_processed = 0;
774-
con.curr_input_mode = tty::restore;
775-
con.curr_output_mode = tty::restore;
776774
}
777775
}
778776

@@ -851,6 +849,11 @@ fhandler_console::set_input_mode (tty::cons_mode m, const termios *t,
851849
flags |= ENABLE_PROCESSED_INPUT;
852850
break;
853851
}
852+
if (con.curr_input_mode != tty::cygwin && m == tty::cygwin)
853+
{
854+
prev_input_mode_backup = con.prev_input_mode;
855+
con.prev_input_mode = oflags;
856+
}
854857
con.curr_input_mode = m;
855858
SetConsoleMode (p->input_handle, flags);
856859
if (!(oflags & ENABLE_VIRTUAL_TERMINAL_INPUT)
@@ -890,6 +893,11 @@ fhandler_console::set_output_mode (tty::cons_mode m, const termios *t,
890893
flags |= DISABLE_NEWLINE_AUTO_RETURN;
891894
break;
892895
}
896+
if (con.curr_output_mode != tty::cygwin && m == tty::cygwin)
897+
{
898+
prev_output_mode_backup = con.prev_output_mode;
899+
GetConsoleMode (p->output_handle, &con.prev_output_mode);
900+
}
893901
con.curr_output_mode = m;
894902
acquire_attach_mutex (mutex_timeout);
895903
DWORD resume_pid = attach_console (con.owner);
@@ -1829,12 +1837,6 @@ fhandler_console::open (int flags, mode_t)
18291837
handle_set.output_handle = h;
18301838
release_output_mutex ();
18311839

1832-
if (con.owner == GetCurrentProcessId ())
1833-
{
1834-
GetConsoleMode (get_handle (), &con.prev_input_mode);
1835-
GetConsoleMode (get_output_handle (), &con.prev_output_mode);
1836-
}
1837-
18381840
wpbuf.init ();
18391841

18401842
handle_set.input_mutex = input_mutex;
@@ -1880,19 +1882,6 @@ fhandler_console::open (int flags, mode_t)
18801882
setenv ("TERM", "cygwin", 1);
18811883
}
18821884

1883-
if (con.curr_input_mode != tty::cygwin)
1884-
{
1885-
prev_input_mode_backup = con.prev_input_mode;
1886-
GetConsoleMode (get_handle (), &con.prev_input_mode);
1887-
set_input_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
1888-
}
1889-
if (con.curr_output_mode != tty::cygwin)
1890-
{
1891-
prev_output_mode_backup = con.prev_output_mode;
1892-
GetConsoleMode (get_output_handle (), &con.prev_output_mode);
1893-
set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
1894-
}
1895-
18961885
debug_printf ("opened conin$ %p, conout$ %p", get_handle (),
18971886
get_output_handle ());
18981887

@@ -4730,7 +4719,7 @@ fhandler_console::cons_mode_on_close (handle_set_t *p)
47304719
NTSTATUS status =
47314720
NtQueryInformationProcess (GetCurrentProcess (), ProcessBasicInformation,
47324721
&pbi, sizeof (pbi), NULL);
4733-
if (NT_SUCCESS (status) && cygwin_pid (con.owner)
4722+
if (NT_SUCCESS (status)
47344723
&& !process_alive ((DWORD) pbi.InheritedFromUniqueProcessId))
47354724
/* Execed from normal cygwin process and the parent has been exited. */
47364725
return tty::cygwin;

0 commit comments

Comments
 (0)