diff options
-rw-r--r-- | winsup/cygwin/fork.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 0119581df..7080144b9 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -424,14 +424,6 @@ frok::parent (volatile char * volatile stack_here) #endif goto cleanup; } - if (!child.reattach ()) - { - this_errno = EAGAIN; -#ifdef DEBUGGING0 - error ("child reattach failed"); -#endif - goto cleanup; - } /* CHILD IS STOPPED */ debug_printf ("child is alive (but stopped)"); @@ -516,6 +508,17 @@ 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 ()) + { + this_errno = EAGAIN; +#ifdef DEBUGGING0 + error ("child reattach failed"); +#endif + goto cleanup; + } + /* Finally start the child up. */ resume_child (forker_finished); |