This is the mail archive of the cygwin-patches mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/2] Cygwin: fork: Attach child not before success.

Do not attach to the child before it was successfully initialized, or we
would need more sophisticated cleanup on child initialization failure,
like suppressing SIGCHILD delivery with multiple threads ("waitproc")

Improves "Cygwin: fork: Remember child not before success.",
commit f03ea8e1c57bd5cea83f6cd47fa02870bdfeb1c5, which leads to fork
problems if cygserver is running:
 winsup/cygwin/ | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/ b/winsup/cygwin/
index 59b13806c..c6ba8cf65 100644
--- a/winsup/cygwin/
+++ b/winsup/cygwin/
@@ -416,11 +416,11 @@ 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_without_attach (false))
       this_errno = EAGAIN;
 #ifdef DEBUGGING0
-      error ("child remember failed");
+      error ("child remember_without_attach failed");
       goto cleanup;
@@ -508,6 +508,15 @@ frok::parent (volatile char * volatile stack_here)
+  if (!child.reattach ())
+    {
+      this_errno = EAGAIN;
+#ifdef DEBUGGING0
+      error ("child reattach failed");
+      goto cleanup;
+    }
   /* Finally start the child up. */
   resume_child (forker_finished);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]