public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: console: Restore CTRL_BREAK_EVENT handling. Date: Thu, 24 Feb 2022 08:46:46 +0000 (GMT) [thread overview] Message-ID: <20220224084646.21A4A385801E@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=132e133f1c5be9a44f33f07e374638ac1485f962 commit 132e133f1c5be9a44f33f07e374638ac1485f962 Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Thu Feb 24 17:28:32 2022 +0900 Cygwin: console: Restore CTRL_BREAK_EVENT handling. - 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; + if (type == 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 = cygwin_shared->tty.get_cttyp (); /* 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 = SIGINT; - /* If intr and quit are both mapped to ^C, send SIGQUIT on ^BREAK */ - if (type == CTRL_BREAK_EVENT - && t->ti.c_cc[VINTR] == 3 && t->ti.c_cc[VQUIT] == 3) - sig = SIGQUIT; t->last_ctrl_c = GetTickCount64 (); - t->kill_pgrp (sig); - t->output_stopped = false; + fhandler_termios::process_sigs ('\003', (tty *) t, ::cygheap->ctty); t->last_ctrl_c = GetTickCount64 (); return TRUE; } diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index e1e0bfb44..f285542cc 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -697,11 +697,7 @@ fhandler_console::bg_check (int sig, bool dontsignal) if (sig == SIGTTIN) { set_input_mode (tty::cygwin, &tc ()->ti, get_handle_set ()); - if (con.disable_master_thread) - { - con.disable_master_thread = false; - init_console_handler (false); - } + con.disable_master_thread = false; } if (sig == SIGTTOU) set_output_mode (tty::cygwin, &tc ()->ti, get_handle_set ()); @@ -1404,7 +1400,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); } @@ -1420,8 +1417,6 @@ fhandler_console::post_open_setup (int fd) else if (fd == 1 || fd == 2) set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set); - init_console_handler (need_console_handler ()); - fhandler_base::post_open_setup (fd); } diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 26dba9096..02d875a7f 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1412,8 +1412,7 @@ wait_sig (VOID *) sig_held = true; break; case __SIGSETPGRP: - if (::cygheap->ctty) - init_console_handler (::cygheap->ctty->need_console_handler ()); + init_console_handler (true); break; case __SIGTHREADEXIT: {
reply other threads:[~2022-02-24 8:46 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220224084646.21A4A385801E@sourceware.org \ --to=tyan0@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).