From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 4B5453858D1E; Sat, 5 Mar 2022 00:06:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B5453858D1E 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: pty: Add several further comments to the pty code. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 21860254da7ba10383a70582e7addc86075fe80d X-Git-Newrev: 6c622490a5004b06b8d714c7fbb73b2caa4fee7a Message-Id: <20220305000612.4B5453858D1E@sourceware.org> Date: Sat, 5 Mar 2022 00:06:12 +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: Sat, 05 Mar 2022 00:06:12 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D6c622490a50= 04b06b8d714c7fbb73b2caa4fee7a commit 6c622490a5004b06b8d714c7fbb73b2caa4fee7a Author: Takashi Yano Date: Sat Mar 5 08:39:05 2022 +0900 Cygwin: pty: Add several further comments to the pty code. Diff: --- winsup/cygwin/fhandler_tty.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 0c762d75e..c2e612580 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -76,6 +76,13 @@ void release_attach_mutex (void) =20 inline static bool process_alive (DWORD pid); =20 +/* This functions looks for a process which attached to the same console + with current process and is matched to given conditions: + match: If true, return given pid if the process pid attaches to the + same console, otherwise, return 0. If false, return pid except + for given pid. + cygwin: return only process's pid which has cygwin pid. + stub_only: return only stub process's pid of non-cygwin process. */ DWORD fhandler_pty_common::get_console_process_id (DWORD pid, bool match, bool cygwin, bool stub_only) @@ -158,6 +165,7 @@ set_switch_to_nat_pipe (HANDLE *in, HANDLE *out, HANDLE= *err) *err =3D replace_err->get_output_handle_nat (); } =20 +/* Determine if the given path is cygwin binary. */ static bool path_iscygexec_a_w (LPCSTR na, LPSTR ca, LPCWSTR nw, LPWSTR cw) { @@ -3860,6 +3868,7 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir= , HANDLE from, tty *ttyp, =20 if (dir =3D=3D tty::to_cyg && ttyp->pcon_activated) { /* from handle is console handle */ + /* Reaches here for nat->cyg case with pcon activated. */ INPUT_RECORD r[INREC_SIZE]; DWORD n; while (PeekConsoleInputA (from, r, INREC_SIZE, &n) && n) @@ -3931,7 +3940,8 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir= , HANDLE from, tty *ttyp, } } else - { + { /* Reaches here when both cyg->nat and nat->cyg cases with + pcon not activated or cyg->nat case with pcon activated. */ DWORD bytes_in_pipe; while (::bytes_available (bytes_in_pipe, from) && bytes_in_pipe) { @@ -3964,9 +3974,11 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir di= r, HANDLE from, tty *ttyp, } } =20 - if (dir =3D=3D tty::to_nat) + /* Fix input_available_event which indicates availability in cyg pipe. */ + if (dir =3D=3D tty::to_nat) /* all data is transfered to nat pipe, + so no data available in cyg pipe. */ ResetEvent (input_available_event); - else if (transfered) + else if (transfered) /* There is data transfered to cyg pipe. */ SetEvent (input_available_event); ttyp->pty_input_state =3D dir; ttyp->discard_input =3D false;