From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 31A8F3858D39; Thu, 3 Mar 2022 18:19:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31A8F3858D39 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: Rename nat_pipe_owner_alive() to process_alive(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 35ba7d147df8df56ef92ea296443d2732ece0445 X-Git-Newrev: d6b778617d3d3869971579427dd45648a2e75030 Message-Id: <20220303181940.31A8F3858D39@sourceware.org> Date: Thu, 3 Mar 2022 18:19:40 +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, 03 Mar 2022 18:19:40 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dd6b778617d3= d3869971579427dd45648a2e75030 commit d6b778617d3d3869971579427dd45648a2e75030 Author: Takashi Yano Date: Thu Mar 3 10:38:05 2022 +0900 Cygwin: pty: Rename nat_pipe_owner_alive() to process_alive(). =20 - The function nat_pipe_owner_alive() is used even for the process which is not a nat pipe owner, so, it is renamed to process_alive(). Diff: --- winsup/cygwin/fhandler_tty.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 43668975f..be3e6fcba 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -74,7 +74,7 @@ void release_attach_mutex (void) ReleaseMutex (attach_mutex); } =20 -inline static bool nat_pipe_owner_alive (DWORD pid); +inline static bool process_alive (DWORD pid); =20 DWORD fhandler_pty_common::get_console_process_id (DWORD pid, bool match, @@ -107,7 +107,7 @@ fhandler_pty_common::get_console_process_id (DWORD pid,= bool match, res_pri =3D stub_only ? p->exec_dwProcessId : list[i]; break; } - if (!p && !res && nat_pipe_owner_alive (list[i]) && stub_only) + if (!p && !res && process_alive (list[i]) && stub_only) res =3D list[i]; if (!!p && !res && !stub_only) res =3D list[i]; @@ -1086,8 +1086,11 @@ fhandler_pty_slave::set_switch_to_nat_pipe (void) } =20 inline static bool -nat_pipe_owner_alive (DWORD pid) +process_alive (DWORD pid) { + /* This function is very similar to _pinfo::alive(), however, this + can be used for non-cygwin process which is started from non-cygwin + shell. In addition, this checks exit code as well. */ if (pid =3D=3D 0) return false; HANDLE h =3D OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid); @@ -1208,7 +1211,7 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void) if (wait_ret =3D=3D WAIT_TIMEOUT) return; if (!nat_pipe_owner_self (get_ttyp ()->nat_pipe_owner_pid) - && nat_pipe_owner_alive (get_ttyp ()->nat_pipe_owner_pid)) + && process_alive (get_ttyp ()->nat_pipe_owner_pid)) { /* There is a process which owns nat pipe. */ if (!to_be_read_from_nat_pipe () @@ -3421,7 +3424,7 @@ skip_create: } while (false); =20 - if (!nat_pipe_owner_alive (get_ttyp ()->nat_pipe_owner_pid)) + if (!process_alive (get_ttyp ()->nat_pipe_owner_pid)) get_ttyp ()->nat_pipe_owner_pid =3D myself->exec_dwProcessId; =20 if (hpcon && nat_pipe_owner_self (get_ttyp ()->nat_pipe_owner_pid)) @@ -4044,7 +4047,7 @@ fhandler_pty_slave::setup_for_non_cygwin_app (bool no= pcon, PWCHAR envblock, { fhandler_pty_slave *ptys =3D (fhandler_pty_slave *) fh; ptys->get_ttyp ()->switch_to_nat_pipe =3D true; - if (!nat_pipe_owner_alive (ptys->get_ttyp ()->nat_pipe_owner_pid)) + if (!process_alive (ptys->get_ttyp ()->nat_pipe_owner_pid)) ptys->get_ttyp ()->nat_pipe_owner_pid =3D myself->exec_dwProcessId; } bool pcon_enabled =3D false;