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: pty: Stop to send CTRL_C_EVENT if pcon activated. Date: Sat, 26 Feb 2022 10:52:28 +0000 (GMT) [thread overview] Message-ID: <20220226105228.5D49B3858414@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d5e5babda58c43de89ac06adccdd72cd24485068 commit d5e5babda58c43de89ac06adccdd72cd24485068 Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Sat Feb 26 04:19:03 2022 +0900 Cygwin: pty: Stop to send CTRL_C_EVENT if pcon activated. - The commit "Cygwin: console: Redesign handling of special keys." removes special treatment for pty in with pseudo console activated, however, it is necessary on second thought. This is because sending CTRL_C_EVENT to non-cygwin apps will be done in pseudo console, therefore, sending it in fhandler_pty_master::write() duplicates that event for non-cygwin apps. Diff: --- winsup/cygwin/fhandler.h | 2 ++ winsup/cygwin/fhandler_termios.cc | 11 ++++------- winsup/cygwin/fhandler_tty.cc | 11 +++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 3acb5986d..eedf2b7d7 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1957,6 +1957,7 @@ class fhandler_termios: public fhandler_base static bool path_iscygexec_w (LPCWSTR n, LPWSTR c); virtual void cleanup_before_exit () {} virtual bool need_console_handler () { return false; } + virtual bool need_send_ctrl_c_event () { return true; } }; enum ansi_intensity @@ -2491,6 +2492,7 @@ public: void get_master_thread_param (master_thread_param_t *p); void get_master_fwd_thread_param (master_fwd_thread_param_t *p); void set_mask_flusho (bool m) { get_ttyp ()->mask_flusho = m; } + bool need_send_ctrl_c_event (); }; class fhandler_dev_null: public fhandler_base diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index b236c1b62..568523390 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -359,16 +359,12 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhandler_termios *fh) instead. */ if ((p->process_state & PID_NEW_PG) && (p->process_state & PID_NOTCYGWIN)) - { - GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, - p->dwProcessId); - need_discard_input = true; - } - else if (!ctrl_c_event_sent) + GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, p->dwProcessId); + else if ((!fh || fh->need_send_ctrl_c_event () || cyg_leader) + && !ctrl_c_event_sent) { GenerateConsoleCtrlEvent (CTRL_C_EVENT, 0); ctrl_c_event_sent = true; - need_discard_input = true; } if (resume_pid && fh && !fh->is_console ()) { @@ -377,6 +373,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhandler_termios *fh) if (::cygheap->ctty && ::cygheap->ctty->is_console ()) init_console_handler (true); } + need_discard_input = true; } if (p && p->ctty == ttyp->ntty && p->pgid == pgid) { diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 979232d96..f82d1e9fd 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -4054,3 +4054,14 @@ fhandler_pty_slave::cleanup_for_non_cygwin_app (handle_set_t *p, tty *ttyp, close_pseudoconsole (ttyp); ReleaseMutex (p->pcon_mutex); } + +bool +fhandler_pty_master::need_send_ctrl_c_event () +{ + /* If pseudo console is activated, sending CTRL_C_EVENT to non-cygwin + apps will be done in pseudo console, therefore, sending it in + fhandler_pty_master::write() duplicates that event for non-cygwin + apps. So return false if pseudo console is activated. */ + return !(to_be_read_from_pcon () && get_ttyp ()->pcon_activated + && get_ttyp ()->pcon_input_state == tty::to_nat); +}
reply other threads:[~2022-02-26 10:52 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=20220226105228.5D49B3858414@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).