From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id E85FA3858020; Thu, 24 Feb 2022 08:47:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E85FA3858020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: console: Restore CTRL_BREAK_EVENT handling. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: acf642177b81543a4d954e58cfb24347c02b125a X-Git-Newrev: 5c4a0824e73d689f0c456e605d74b03dcb2f7aec Message-Id: <20220224084706.E85FA3858020@sourceware.org> Date: Thu, 24 Feb 2022 08:47:06 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2022 08:47:07 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D5c4a0824e73= d689f0c456e605d74b03dcb2f7aec commit 5c4a0824e73d689f0c456e605d74b03dcb2f7aec Author: Takashi Yano Date: Thu Feb 24 17:28:32 2022 +0900 Cygwin: console: Restore CTRL_BREAK_EVENT handling. =20 - The recent change by the commit "Cygwin: console: Redesign handling of special keys." breaks the handling of CTRL_BREAK_EVENT. The login shell in console exits on Ctrl-Break key. This patch fixes the issue. Diff: --- winsup/cygwin/exceptions.cc | 13 ++++++------- winsup/cygwin/fhandler_console.cc | 11 +++-------- winsup/cygwin/sigproc.cc | 3 +-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 356d69d6a..73bf68939 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1146,6 +1146,11 @@ ctrl_c_handler (DWORD type) if (!pinfo (cygwin_pid (GetCurrentProcessId ()))) return TRUE; =20 + if (type =3D=3D CTRL_C_EVENT && ::cygheap->ctty + && !cygheap->ctty->need_console_handler ()) + /* Ctrl-C is handled in fhandler_console::cons_master_thread(). */ + return TRUE; + tty_min *t =3D cygwin_shared->tty.get_cttyp (); =20 /* If process group leader is non-cygwin process or not exist, @@ -1169,14 +1174,8 @@ ctrl_c_handler (DWORD type) (to indicate that we have handled the signal). At this point, type should be a CTRL_C_EVENT or CTRL_BREAK_EVENT. */ { - int sig =3D SIGINT; - /* If intr and quit are both mapped to ^C, send SIGQUIT on ^BREAK */ - if (type =3D=3D CTRL_BREAK_EVENT - && t->ti.c_cc[VINTR] =3D=3D 3 && t->ti.c_cc[VQUIT] =3D=3D 3) - sig =3D SIGQUIT; t->last_ctrl_c =3D GetTickCount64 (); - t->kill_pgrp (sig); - t->output_stopped =3D false; + fhandler_termios::process_sigs ('\003', (tty *) t, ::cygheap->ctty); t->last_ctrl_c =3D GetTickCount64 (); return TRUE; } diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_con= sole.cc index b290cde08..843a96f9a 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -699,11 +699,7 @@ fhandler_console::bg_check (int sig, bool dontsignal) if (sig =3D=3D SIGTTIN) { set_input_mode (tty::cygwin, &tc ()->ti, get_handle_set ()); - if (con.disable_master_thread) - { - con.disable_master_thread =3D false; - init_console_handler (false); - } + con.disable_master_thread =3D false; } if (sig =3D=3D SIGTTOU) set_output_mode (tty::cygwin, &tc ()->ti, get_handle_set ()); @@ -1406,7 +1402,8 @@ bool fhandler_console::open_setup (int flags) { set_flags ((flags & ~O_TEXT) | O_BINARY); - myself->set_ctty (this, flags); + if (myself->set_ctty (this, flags) && !myself->cygstarted) + init_console_handler (true); return fhandler_base::open_setup (flags); } =20 @@ -1422,8 +1419,6 @@ fhandler_console::post_open_setup (int fd) else if (fd =3D=3D 1 || fd =3D=3D 2) set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set); =20 - init_console_handler (need_console_handler ()); - fhandler_base::post_open_setup (fd); } =20 diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 16ea5031b..4d7d273ae 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1392,8 +1392,7 @@ wait_sig (VOID *) sig_held =3D true; break; case __SIGSETPGRP: - if (::cygheap->ctty) - init_console_handler (::cygheap->ctty->need_console_handler ()); + init_console_handler (true); break; case __SIGTHREADEXIT: {