public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pinfo: stop remember doing reattach Date: Wed, 31 Jul 2019 16:58:00 -0000 [thread overview] Message-ID: <20190731165853.35476.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=23a779bf3d7c2afc9eab88f6b8727c1db5544547 commit 23a779bf3d7c2afc9eab88f6b8727c1db5544547 Author: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com> Date: Wed Jul 31 12:35:31 2019 +0200 Cygwin: pinfo: stop remember doing reattach 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 Diff: --- winsup/cygwin/fork.cc | 8 ++++++++ winsup/cygwin/sigproc.cc | 7 +++---- winsup/cygwin/spawn.cc | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 59b1380..0119581 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -424,6 +424,14 @@ 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)"); diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 900facd..8003e2d 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -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); } diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 579b3c9..7f7af44 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -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);
reply other threads:[~2019-07-31 16:58 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190731165853.35476.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).