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: pty: Rename nat_pipe_owner_alive() to process_alive().
Date: Thu,  3 Mar 2022 18:19:40 +0000 (GMT)	[thread overview]
Message-ID: <20220303181940.31A8F3858D39@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d6b778617d3d3869971579427dd45648a2e75030

commit d6b778617d3d3869971579427dd45648a2e75030
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Thu Mar 3 10:38:05 2022 +0900

    Cygwin: pty: Rename nat_pipe_owner_alive() to process_alive().
    
    - 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);
 }
 
-inline static bool nat_pipe_owner_alive (DWORD pid);
+inline static bool process_alive (DWORD pid);
 
 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 = 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 = list[i];
 	    if (!!p && !res && !stub_only)
 	      res = list[i];
@@ -1086,8 +1086,11 @@ fhandler_pty_slave::set_switch_to_nat_pipe (void)
 }
 
 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 == 0)
     return false;
   HANDLE h = OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
@@ -1208,7 +1211,7 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void)
   if (wait_ret == 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);
 
-  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 = myself->exec_dwProcessId;
 
   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 nopcon, PWCHAR envblock,
     {
       fhandler_pty_slave *ptys = (fhandler_pty_slave *) fh;
       ptys->get_ttyp ()->switch_to_nat_pipe = 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 = myself->exec_dwProcessId;
     }
   bool pcon_enabled = false;


                 reply	other threads:[~2022-03-03 18:19 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=20220303181940.31A8F3858D39@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: link
Be 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).