]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: drop PROC_DETACHED_CHILD flag
authorCorinna Vinschen <corinna@vinschen.de>
Fri, 28 Aug 2020 09:10:48 +0000 (11:10 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Fri, 28 Aug 2020 09:10:48 +0000 (11:10 +0200)
pinfo::remember with the detach parameter set to true is
the only way to call proc_subproc with PROC_DETACHED_CHILD.
This call is exclusively used in spawn to set up a pinfo for
a detached child, and that pinfo goes out of scope right
afterwards without any further action.

Drop the flag and drop the detach parameter from pinfo::remember.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/fork.cc
winsup/cygwin/pinfo.h
winsup/cygwin/sigproc.cc
winsup/cygwin/sigproc.h
winsup/cygwin/spawn.cc

index 43a92738c47943afb0d72c08ed6c1fe3619802a3..719217856ae3d342ae9e4b7f8588690396282add 100644 (file)
@@ -415,7 +415,7 @@ frok::parent (volatile char * volatile stack_here)
      it in afterwards.  This requires more bookkeeping than I like, though,
      so we'll just do it the easy way.  So, terminate any child process if
      we can't actually record the pid in the internal table. */
-  if (!child.remember (false))
+  if (!child.remember ())
     {
       this_errno = EAGAIN;
 #ifdef DEBUGGING0
index 2db7d6a01e979ef408b9c4e057560f72fe8237c4..69c1223f3829617eb8257a90d2c6ffb622d81a4c 100644 (file)
@@ -196,10 +196,9 @@ public:
     destroy = res ? false : true;
     return res;
   }
-  int remember (bool detach)
+  int remember ()
   {
-    int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADD_CHILD,
-                           (uintptr_t) this);
+    int res = proc_subproc (PROC_ADD_CHILD, (uintptr_t) this);
     destroy = res ? false : true;
     return res;
   }
index 7679f76f4ee3ea9821e06d98f65b78e9a5340e18..ba1e64b33b85645701c95655f08567029b3f8e24 100644 (file)
@@ -205,9 +205,6 @@ proc_subproc (DWORD what, uintptr_t val)
          set_errno (EAGAIN);
          break;
        }
-      fallthrough;
-
-    case PROC_DETACHED_CHILD:
       if (vchild != myself)
        {
          vchild->uid = myself->uid;
@@ -217,8 +214,7 @@ 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 = myself->pid;   /* always set last */
        }
       break;
 
@@ -879,7 +875,7 @@ void
 child_info_spawn::wait_for_myself ()
 {
   postfork (myself);
-  if (myself.remember (false))
+  if (myself.remember ())
     myself.attach ();
   WaitForSingleObject (ev, INFINITE);
 }
index 3d4e766a20f4a1c5cd11926ff75191867273b47e..2a3d248d199c5fd22e1581c14cca181d7c19fe3e 100644 (file)
@@ -33,11 +33,10 @@ enum procstuff
   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
-  PROC_WAIT              = 6,  // setup for wait() for subproc
-  PROC_EXECING           = 7,  // used to get a lock when execing
-  PROC_NOTHING           = 8   // nothing, really
+  PROC_CLEARWAIT         = 4,  // clear all waits - signal arrived
+  PROC_WAIT              = 5,  // setup for wait() for subproc
+  PROC_EXECING           = 6,  // used to get a lock when execing
+  PROC_NOTHING           = 7   // nothing, really
 };
 
 struct sigpacket
index 1efcdb3663208cf8e8bea6839dba648b54f8c0ab..a2f7697d7f3ca904e7e368ff78aac4186f6269f1 100644 (file)
@@ -867,9 +867,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
          child->start_time = time (NULL); /* Register child's starting time. */
          child->nice = myself->nice;
          postfork (child);
-         if (mode == _P_DETACH
-             ? !child.remember (true)
-             : !(child.remember (false) && child.attach ()))
+         if (mode != _P_DETACH
+             && (!child.remember () || !child.attach ()))
            {
              /* FIXME: Child in strange state now */
              CloseHandle (pi.hProcess);
This page took 0.03729 seconds and 5 git commands to generate.