summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>2019-04-30 09:09:13 +0200
committerCorinna Vinschen <corinna@vinschen.de>2019-06-03 18:40:35 +0200
commita8c23e4423ebb3458db93341d8a9bc73b0a04b03 (patch)
tree7f6d0f7704ef4cb2566cc1e974dba0d4b8ec5270
parenta9c27900e3d98fa4e57405e7abc10c260f2167d2 (diff)
downloadcygnal-a8c23e4423ebb3458db93341d8a9bc73b0a04b03.tar.gz
cygnal-a8c23e4423ebb3458db93341d8a9bc73b0a04b03.tar.bz2
cygnal-a8c23e4423ebb3458db93341d8a9bc73b0a04b03.zip
Cygwin: fork: Always pause child after fixups.
Pause the child process after performing fork fixups even if there were no dynamically loaded dlls with extra data/bss transfers to wait for. This allows the parent process to cancel the current fork call even if the child process was successfully initialized already. This is a preparation for when the parent does remember the child no earlier than after successful child initialization.
-rw-r--r--winsup/cygwin/fork.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 7e1c08990..59b13806c 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -180,13 +180,10 @@ frok::child (volatile char * volatile here)
cygheap->fdtab.fixup_after_fork (hParent);
- /* If we haven't dynamically loaded any dlls, just signal the parent.
- Otherwise, tell the parent that we've loaded all the dlls
- and wait for the parent to fill in the loaded dlls' data/bss. */
- if (!load_dlls)
- sync_with_parent ("performed fork fixup", false);
- else
- sync_with_parent ("loaded dlls", true);
+ /* Signal that we have successfully initialized, so the parent can
+ - transfer data/bss for dynamically loaded dlls (if any), or
+ - terminate the current fork call even if the child is initialized. */
+ sync_with_parent ("performed fork fixups and dynamic dll loading", true);
init_console_handler (myself->ctty > 0);
ForceCloseHandle1 (fork_info->forker_finished, forker_finished);
@@ -477,7 +474,8 @@ frok::parent (volatile char * volatile stack_here)
}
}
- /* Start thread, and then wait for it to reload dlls. */
+ /* Start the child up, and then wait for it to
+ perform fork fixups and dynamic dll loading (if any). */
resume_child (forker_finished);
if (!ch.sync (child->pid, hchild, FORK_WAIT_TIMEOUT))
{
@@ -508,10 +506,11 @@ frok::parent (volatile char * volatile stack_here)
goto cleanup;
}
}
- /* Start the child up again. */
- resume_child (forker_finished);
}
+ /* Finally start the child up. */
+ resume_child (forker_finished);
+
ForceCloseHandle (forker_finished);
forker_finished = NULL;