diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-06-01 13:44:41 +0300 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-06-01 14:15:21 +0300 |
commit | 3456e8b7db5b37cf9e10aedbbf552df10f75e055 (patch) | |
tree | 0d73fd74ab89155ce6391b1899820a088a163abd /winsup | |
parent | deca777a958cad67faa73d7457ecccd8c73ed943 (diff) |
Cygwin: pty: Fix transferring type-ahead input between input pipes.
After the commit 595fcb21ffc0, transferring type-ahead input between
the pipe for cygwin app and the pipe for non-cygwin app will not be
done appropriately when the stdin of the non-cygwin app is not pty.
Due to this issue, sometimes the keyboard input might be lost which
should be sent to cygwin app. This patch fixes the issue.
Fixes: 595fcb21ffc0 ("Cygwin: pty: Fix reading CONIN$ when stdin is not a pty.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/fhandler/pty.cc | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index aa7ceb0ba..9ca3b64b6 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -1298,17 +1298,7 @@ fhandler_pty_slave::mask_switch_to_nat_pipe (bool mask, bool xfer) else if (InterlockedDecrement (&num_reader) == 0) CloseHandle (slave_reading); - /* This is needed when cygwin-app is started from non-cygwin app if - pseudo console is disabled. */ - bool need_xfer = get_ttyp ()->nat_fg (get_ttyp ()->getpgid ()) - && get_ttyp ()->switch_to_nat_pipe && !get_ttyp ()->pcon_activated; - - /* In GDB, transfer input based on setpgid() does not work because - GDB may not set terminal process group properly. Therefore, - transfer input here if isHybrid is set. */ - bool need_gdb_xfer = - isHybrid && GetStdHandle (STD_INPUT_HANDLE) == get_handle (); - if (!!masked != mask && xfer && (need_gdb_xfer || need_xfer)) + if (!!masked != mask && xfer && get_ttyp ()->switch_to_nat_pipe) { if (mask && get_ttyp ()->pty_input_state_eq (tty::to_nat)) { @@ -2240,11 +2230,7 @@ fhandler_pty_master::write (const void *ptr, size_t len) if (!get_ttyp ()->pcon_start) { /* Pseudo console initialization has been done in above code. */ pinfo pp (get_ttyp ()->pcon_start_pid); - bool pcon_fg = (pp && get_ttyp ()->getpgid () == pp->pgid); - /* GDB may set WINPID rather than cygwin PID to process group - when the debugged process is a non-cygwin process.*/ - pcon_fg |= !pinfo (get_ttyp ()->getpgid ()); - if (get_ttyp ()->switch_to_nat_pipe && pcon_fg + if (get_ttyp ()->switch_to_nat_pipe && get_ttyp ()->pty_input_state_eq (tty::to_cyg)) { /* This accept_input() call is needed in order to transfer input @@ -4142,7 +4128,7 @@ fhandler_pty_slave::cleanup_for_non_cygwin_app (handle_set_t *p, tty *ttyp, DWORD force_switch_to) { ttyp->wait_fwd (); - if (ttyp->getpgid () == myself->pgid && stdin_is_ptys + if ((ttyp->pcon_activated || stdin_is_ptys) && ttyp->pty_input_state_eq (tty::to_nat)) { WaitForSingleObject (p->input_mutex, mutex_timeout); |