* 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.
This commit is contained in:
@@ -828,7 +828,8 @@ child_info::child_info (unsigned in_cb, child_info_types chtype,
|
||||
bool need_subproc_ready):
|
||||
cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC),
|
||||
type (chtype), cygheap (::cygheap), cygheap_max (::cygheap_max),
|
||||
flag (0), retry (child_info::retry_count)
|
||||
flag (0), retry (child_info::retry_count), rd_proc_pipe (NULL),
|
||||
wr_proc_pipe (NULL)
|
||||
{
|
||||
/* It appears that when running under WOW64 on Vista 64, the first DWORD
|
||||
value in the datastructure lpReserved2 is pointing to (msv_count in
|
||||
@@ -876,14 +877,12 @@ child_info::child_info (unsigned in_cb, child_info_types chtype,
|
||||
|
||||
child_info::~child_info ()
|
||||
{
|
||||
if (subproc_ready)
|
||||
CloseHandle (subproc_ready);
|
||||
if (parent)
|
||||
CloseHandle (parent);
|
||||
cleanup ();
|
||||
}
|
||||
|
||||
child_info_fork::child_info_fork () :
|
||||
child_info (sizeof *this, _CH_FORK, true)
|
||||
child_info (sizeof *this, _CH_FORK, true),
|
||||
forker_finished (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -893,7 +892,7 @@ child_info_spawn::child_info_spawn (child_info_types chtype, bool need_subproc_r
|
||||
if (type == _CH_EXEC)
|
||||
{
|
||||
hExeced = NULL;
|
||||
if (myself->wr_proc_pipe)
|
||||
if (my_wr_proc_pipe)
|
||||
ev = NULL;
|
||||
else if (!(ev = CreateEvent (&sec_none_nih, false, false, NULL)))
|
||||
api_fatal ("couldn't create signalling event for exec, %E");
|
||||
@@ -912,6 +911,31 @@ cygheap_exec_info::alloc ()
|
||||
+ (nprocs * sizeof (children[0])));
|
||||
}
|
||||
|
||||
void
|
||||
child_info::cleanup ()
|
||||
{
|
||||
if (subproc_ready)
|
||||
{
|
||||
CloseHandle (subproc_ready);
|
||||
subproc_ready = NULL;
|
||||
}
|
||||
if (parent)
|
||||
{
|
||||
CloseHandle (parent);
|
||||
parent = NULL;
|
||||
}
|
||||
if (rd_proc_pipe)
|
||||
{
|
||||
ForceCloseHandle (rd_proc_pipe);
|
||||
rd_proc_pipe = NULL;
|
||||
}
|
||||
if (wr_proc_pipe)
|
||||
{
|
||||
ForceCloseHandle (wr_proc_pipe);
|
||||
wr_proc_pipe = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
child_info_spawn::cleanup ()
|
||||
{
|
||||
@@ -940,6 +964,7 @@ child_info_spawn::cleanup ()
|
||||
sync_proc_subproc.release ();
|
||||
}
|
||||
type = _CH_NADA;
|
||||
child_info::cleanup ();
|
||||
}
|
||||
|
||||
/* Record any non-reaped subprocesses to be passed to about-to-be-execed
|
||||
@@ -1047,7 +1072,7 @@ child_info::sync (pid_t pid, HANDLE& hProcess, DWORD howlong)
|
||||
{
|
||||
res = true;
|
||||
exit_code = STILL_ACTIVE;
|
||||
if (type == _CH_EXEC && myself->wr_proc_pipe)
|
||||
if (type == _CH_EXEC && my_wr_proc_pipe)
|
||||
{
|
||||
ForceCloseHandle1 (hProcess, childhProc);
|
||||
hProcess = NULL;
|
||||
|
Reference in New Issue
Block a user