aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/dcrt0.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-03-20 15:07:30 +0000
committerChristopher Faylor <me@cgf.cx>2012-03-20 15:07:30 +0000
commit1fb6667f1ca346ab7f845b1adcb146a7d6e243fc (patch)
treed7619da1a2bce1baf30740f17e7b4690e5996466 /winsup/cygwin/dcrt0.cc
parente9a6f9c6259960156a999ab2b207adf7ede1a088 (diff)
downloadnewlib-1fb6667f1ca346ab7f845b1adcb146a7d6e243fc.zip
newlib-1fb6667f1ca346ab7f845b1adcb146a7d6e243fc.tar.gz
newlib-1fb6667f1ca346ab7f845b1adcb146a7d6e243fc.tar.bz2
* child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(child_info::rd_proc_pipe): Declare new field. (child_info::wr_proc_pipe): Ditto. (child_info::prefork): Declare new function, derived from previous pinfo version. * dcrt0.cc (child_info_fork::handle_fork): Close previous wr_proc_pipe when appropriate and assign new one from passed-in child_info block. (child_info_spawn::handle_spawn): Assign our wr_proc_pipe handle from passed-in child_info block. * fork.cc (child_info::prefork): Define new function. (frok::child): Clear rd_proc_pipe and wr_proc_pipe so they will not be closed by the child_info destructor. (frok::parent): Use child_info prefork handling, outside of retry loop. Set rd_proc_pipe in child's pinfo after successful CreateProcess. Eliminate postfork call. * globals.cc (my_wr_proc_pipe): Define/declare new variable. * pinfo.cc (pinfo::pending_rd_proc_pipe): Delete. (pinfo::pending_wr_proc_pipe): Ditto. (pinfo::prefork): Ditto. (pinfo::postfork): Ditto. (pinfo::postexec): Ditto. (pinfo::wait): Assume that rd_proc_pipe is set up correctly prior to call. (_pinfo::alert_parent): Replace "wr_proc_pipe" with "my_wr_proc_pipe". * pinfo.h (_pinfo::_wr_proc_pipe): Delete declaration. (_pinfo::set_rd_proc_pipe): Define new function. (pinfo::pending_rd_proc_pipe): Delete declaration. (pinfo::pending_wr_proc_pipe): Ditto. (pinfo::prefork): Ditto. (pinfo::postfork): Ditto. (pinfo::postexec): Ditto. (pinfo::wr_proc_pipe): Ditto. * sigproc.cc (child_info::child_info): Clear rd_proc_pipe and wr_proc_pipe. (child_info::cleanup): Close rd_proc_pipe and wr_proc_pipe if necessary. (child_info_fork::child_info_fork): Set forker_finished to NULL by default. (child_info_spawn::child_info_spawn): Use my_wr_proc_pipe rather than myself->wr_proc_pipe. (child_info::sync): Ditto. (child_info_spawn::cleanup): Call child_info::cleanup. * spawn.cc (child_info_spawn::worker): Remove call to myself.prefork(). Set wr_proc_pipe when execing or set up new rd_proc_pipe/wr_proc_pipe via child_info::prefork when spawning. Remove call to pinfo::postexec. Set rd_proc_pipe in child pinfo when spawning. Use my_wr_proc_pipe rather than myself->wr_proc_pipe. Remove call to postfork.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r--winsup/cygwin/dcrt0.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index e7a35f2..d35ca6b 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -598,6 +598,17 @@ child_info_fork::handle_fork ()
"user heap", cygheap->user_heap.base, cygheap->user_heap.ptr,
NULL);
+ /* If my_wr_proc_pipe != NULL then it's a leftover handle from a previously
+ forked process. Close it now or suffer confusion with the parent of our
+ parent. */
+ if (my_wr_proc_pipe)
+ ForceCloseHandle1 (my_wr_proc_pipe, wr_proc_pipe);
+
+ /* Setup our write end of the process pipe. Clear the one in the structure.
+ The destructor should never be called for this but, it can't hurt to be
+ safe. */
+ my_wr_proc_pipe = wr_proc_pipe;
+ rd_proc_pipe = wr_proc_pipe = NULL;
/* Do the relocations here. These will actually likely be overwritten by the
below child_copy but we do them here in case there is a read-only section
which does not get copied by fork. */
@@ -626,6 +637,13 @@ child_info_spawn::handle_spawn ()
GetCurrentProcess (), &h, 0,
FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
h = NULL;
+
+ /* Setup our write end of the process pipe. Clear the one in the structure.
+ The destructor should never be called for this but, it can't hurt to be
+ safe. */
+ my_wr_proc_pipe = wr_proc_pipe;
+ rd_proc_pipe = wr_proc_pipe = NULL;
+
myself.thisproc (h);
__argc = moreinfo->argc;
__argv = moreinfo->argv;