]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pinfo: stop remember doing reattach
authorMichael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Wed, 31 Jul 2019 10:35:31 +0000 (12:35 +0200)
committerCorinna Vinschen <corinna-cygwin@cygwin.com>
Wed, 31 Jul 2019 11:27:47 +0000 (13:27 +0200)
During fork, the child process requires the process table to be
initialized for fixup_shms_after_fork, while still allowing subsequent
dlls.load_after_fork to fail silently (for when the "forkable" hardlinks
are not created yet).
pinfo::remember not performing reattach anymore requires explicit
pinfo::reattach now where appropriate.

Prepares to improve "Cygwin: fork: Remember child not before success."
commit f03ea8e1c57bd5cea83f6cd47fa02870bdfeb1c5, which leads to fork
problems if cygserver is running:

https://cygwin.com/ml/cygwin-patches/2019-q2/msg00155.html

winsup/cygwin/fork.cc
winsup/cygwin/sigproc.cc
winsup/cygwin/spawn.cc

index 59b13806c465bd051da77a25343ec8ef92b11d65..0119581df28ead2b1fe0adcb1b278ffe17f05be7 100644 (file)
@@ -421,6 +421,14 @@ frok::parent (volatile char * volatile stack_here)
       this_errno = EAGAIN;
 #ifdef DEBUGGING0
       error ("child remember failed");
+#endif
+      goto cleanup;
+    }
+  if (!child.reattach ())
+    {
+      this_errno = EAGAIN;
+#ifdef DEBUGGING0
+      error ("child reattach failed");
 #endif
       goto cleanup;
     }
index 900facd58e3ca95c693259b8975df510c5faddbd..8003e2db62595c6415f126fb096d88c62ccb71f3 100644 (file)
@@ -216,9 +216,7 @@ proc_subproc (DWORD what, uintptr_t val)
          vchild->process_state |= PID_INITIALIZING;
          vchild->ppid = what == PROC_DETACHED_CHILD ? 1 : myself->pid; /* always set last */
        }
-      if (what == PROC_DETACHED_CHILD)
-       break;
-      /* fall through intentionally */
+      break;
 
     case PROC_REATTACH_CHILD:
       procs[nprocs] = vchild;
@@ -873,7 +871,8 @@ void
 child_info_spawn::wait_for_myself ()
 {
   postfork (myself);
-  myself.remember (false);
+  if (myself.remember (false))
+    myself.reattach ();
   WaitForSingleObject (ev, INFINITE);
 }
 
index 579b3c9c324195f6add964fa0a7e3e865a6360c6..7f7af4449da13248b595e41a16ca6b9e31b51f8c 100644 (file)
@@ -779,7 +779,9 @@ 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 (!child.remember (mode == _P_DETACH))
+         if (mode == _P_DETACH
+             ? !child.remember (true)
+             : !(child.remember (false) && child.reattach ()))
            {
              /* FIXME: Child in strange state now */
              CloseHandle (pi.hProcess);
This page took 0.03693 seconds and 5 git commands to generate.