public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fix up proc_subproc flags and matching pinfo methods
@ 2020-08-28 13:23 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2020-08-28 13:23 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 0a31ad6f4c8bf18864b0be3546b402db0a6108f7
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Aug 27 21:38:50 2020 +0200

    Cygwin: fix up proc_subproc flags and matching pinfo methods
    
    After patch 23a779bf3d7c2afc9eab88f6b8727c1db5544547
    "Cygwin: pinfo: stop remember doing reattach",
    PROC_ADDCHILD actually just sets up a new child, mirroring
    PROC_DETACHED_CHILD.  The actual attaching of the child is
    performed by action PROC_REATTACH_CHILD or pinfo::reattach
    respectively.
    
    To better reflect what's going on, rename PROC_REATTACH_CHILD
    to PROC_ATTACH_CHILD and rename pinfo::reattach to pinfo::attach.
    For better readability change PROC_ADDCHILD to PROC_ADD_CHILD.
    Fix comments accordingly.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fork.cc    |  4 ++--
 winsup/cygwin/pinfo.h    |  8 ++++----
 winsup/cygwin/sigproc.cc | 11 ++++++-----
 winsup/cygwin/sigproc.h  |  4 ++--
 winsup/cygwin/spawn.cc   |  2 +-
 5 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 38172ca1e..43a92738c 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -509,11 +509,11 @@ frok::parent (volatile char * volatile stack_here)
 
   /* Do not attach to the child before it has successfully initialized.
      Otherwise we may wait forever, or deliver an orphan SIGCHILD. */
-  if (!child.reattach ())
+  if (!child.attach ())
     {
       this_errno = EAGAIN;
 #ifdef DEBUGGING0
-      error ("child reattach failed");
+      error ("child attach failed");
 #endif
       goto cleanup;
     }
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 23f308360..2db7d6a01 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -187,18 +187,18 @@ public:
   void preserve () { destroy = false; }
   void allow_remove () { destroy = true; }
 #ifndef SIG_BAD_MASK		// kludge to ensure that sigproc.h included
-  // int reattach () {system_printf ("reattach is not here"); return 0;}
+  // int attach () {system_printf ("attach is not here"); return 0;}
   // int remember (bool) {system_printf ("remember is not here"); return 0;}
 #else
-  int reattach ()
+  int attach ()
   {
-    int res = proc_subproc (PROC_REATTACH_CHILD, (uintptr_t) this);
+    int res = proc_subproc (PROC_ATTACH_CHILD, (uintptr_t) this);
     destroy = res ? false : true;
     return res;
   }
   int remember (bool detach)
   {
-    int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADDCHILD,
+    int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADD_CHILD,
 			    (uintptr_t) this);
     destroy = res ? false : true;
     return res;
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index a5cf73bde..b29835ee6 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -195,7 +195,7 @@ proc_subproc (DWORD what, uintptr_t val)
     /* Add a new subprocess to the children arrays.
      * (usually called from the main thread)
      */
-    case PROC_ADDCHILD:
+    case PROC_ADD_CHILD:
       /* Filled up process table? */
       if (nprocs >= NPROCS)
 	{
@@ -217,11 +217,12 @@ proc_subproc (DWORD what, uintptr_t val)
 	  vchild->ctty = myself->ctty;
 	  vchild->cygstarted = true;
 	  vchild->process_state |= PID_INITIALIZING;
-	  vchild->ppid = what == PROC_DETACHED_CHILD ? 1 : myself->pid;	/* always set last */
+	  vchild->ppid = what == PROC_DETACHED_CHILD
+				 ? 1 : myself->pid;	/* always set last */
 	}
       break;
 
-    case PROC_REATTACH_CHILD:
+    case PROC_ATTACH_CHILD:
       procs[nprocs] = vchild;
       rc = procs[nprocs].wait ();
       if (rc)
@@ -879,7 +880,7 @@ child_info_spawn::wait_for_myself ()
 {
   postfork (myself);
   if (myself.remember (false))
-    myself.reattach ();
+    myself.attach ();
   WaitForSingleObject (ev, INFINITE);
 }
 
@@ -973,7 +974,7 @@ cygheap_exec_info::reattach_children (HANDLE parent)
       pinfo p (parent, children[i].p, children[i].pid);
       if (!p)
 	debug_only_printf ("couldn't reattach child %d from previous process", children[i].pid);
-      else if (!p.reattach ())
+      else if (!p.attach ())
 	debug_only_printf ("attach of child process %d failed", children[i].pid);
       else
 	debug_only_printf ("reattached pid %d<%u>, process handle %p, rd_proc_pipe %p->%p",
diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h
index f8f92d350..f6702f4a3 100644
--- a/winsup/cygwin/sigproc.h
+++ b/winsup/cygwin/sigproc.h
@@ -30,8 +30,8 @@ enum
 
 enum procstuff
 {
-  PROC_ADDCHILD		  = 1,	// add a new subprocess to list
-  PROC_REATTACH_CHILD	  = 2,	// reattach after exec
+  PROC_ADD_CHILD	  = 1,	// set up a new child
+  PROC_ATTACH_CHILD	  = 2,	// attach child or reattach after exec
   PROC_EXEC_CLEANUP	  = 3,	// cleanup waiting children after exec
   PROC_DETACHED_CHILD	  = 4,	// set up a detached child
   PROC_CLEARWAIT	  = 5,	// clear all waits - signal arrived
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 8308bccf3..1efcdb366 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -869,7 +869,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
 	  postfork (child);
 	  if (mode == _P_DETACH
 	      ? !child.remember (true)
-	      : !(child.remember (false) && child.reattach ()))
+	      : !(child.remember (false) && child.attach ()))
 	    {
 	      /* FIXME: Child in strange state now */
 	      CloseHandle (pi.hProcess);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-28 13:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 13:23 [newlib-cygwin] Cygwin: fix up proc_subproc flags and matching pinfo methods Corinna Vinschen

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).