On Wed, 9 Apr 2025 16:41:18 -0700 (PDT) Jeremy Drake wrote: > I've been doing some building with cmake 4.0.0 and ninja 1.12.1 (of > llvm/clang, we've got something that seems to mostly work for a cygwin > target), and I'm noticing after updating to 3.6.1 it no longer seems to > cancel the build when I hit Ctrl-C (previously I was still on 3.5 due to > the cmake/ninja issue which was fixed in 3.6.1). This is from Windows > Terminal. > > Has anyone else noticed issues with Ctrl-C being ignored in 3.6?
This may occur if the parent process is exited befor the child process exits. This is due to a bug introduced by: 3312f2d21f13 ("Cygwin: console: Redesign mode set strategy on close().") Could you please test if the patch attached helps? -- Takashi Yano <takashi.y...@nifty.ne.jp>
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc index a38487f9b..f33e354c2 100644 --- a/winsup/cygwin/fhandler/console.cc +++ b/winsup/cygwin/fhandler/console.cc @@ -932,7 +932,7 @@ fhandler_console::cleanup_for_non_cygwin_app (handle_set_t *p) /* Cleaning-up console mode for non-cygwin app. */ /* conmode can be tty::restore when non-cygwin app is exec'ed from login shell. */ - tty::cons_mode conmode = cons_mode_on_close (); + tty::cons_mode conmode = cons_mode_on_close (p); set_output_mode (conmode, ti, p); set_input_mode (conmode, ti, p); set_disable_master_thread (con.owner == GetCurrentProcessId ()); @@ -1991,8 +1991,9 @@ fhandler_console::close (int flag) acquire_output_mutex (mutex_timeout); - if (shared_console_info[unit] && myself->ppid == 1 - && (dev_t) myself->ctty == get_device ()) + if (shared_console_info[unit] && con.curr_input_mode != tty::restore + && (dev_t) myself->ctty == get_device () + && cons_mode_on_close (&handle_set) == tty::restore) { set_output_mode (tty::restore, &get_ttyp ()->ti, &handle_set); set_input_mode (tty::restore, &get_ttyp ()->ti, &handle_set); @@ -4704,10 +4705,25 @@ fhandler_console::fstat (struct stat *st) } tty::cons_mode -fhandler_console::cons_mode_on_close () +fhandler_console::cons_mode_on_close (handle_set_t *p) { + int unit = p->unit; if (myself->ppid != 1) /* Execed from normal cygwin process. */ return tty::cygwin; + if (!process_alive (con.owner)) /* The Master process already died. */ + return tty::restore; + if (con.owner == GetCurrentProcessId ()) /* Master process */ + return tty::restore; + + PROCESS_BASIC_INFORMATION pbi; + NTSTATUS status = + NtQueryInformationProcess (GetCurrentProcess (), ProcessBasicInformation, + &pbi, sizeof (pbi), NULL); + if (NT_SUCCESS (status) + && !process_alive ((DWORD) pbi.InheritedFromUniqueProcessId)) + /* Execed from normal cygwin process and the parent has been exited. */ + return tty::cygwin; + return tty::restore; /* otherwise, restore */ } diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h index 8c71d8495..4c013dd4a 100644 --- a/winsup/cygwin/local_includes/fhandler.h +++ b/winsup/cygwin/local_includes/fhandler.h @@ -2368,7 +2368,7 @@ private: void setup_pcon_hand_over (); static void pcon_hand_over_proc (); - static tty::cons_mode cons_mode_on_close (); + static tty::cons_mode cons_mode_on_close (handle_set_t *); friend tty_min * tty_list::get_cttyp (); };
-- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple