summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/sigproc.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-01-17 04:12:08 +0000
committerChristopher Faylor <me@cgf.cx>2005-01-17 04:12:08 +0000
commit37d5841f83200da2d481d6b01c111a37acf8ca39 (patch)
treec592a64c0ad15e0fe42b40e6481797d183bd41a3 /winsup/cygwin/sigproc.cc
parent459a95619788793541553674eb5bb59888aa7f6a (diff)
downloadcygnal-37d5841f83200da2d481d6b01c111a37acf8ca39.tar.gz
cygnal-37d5841f83200da2d481d6b01c111a37acf8ca39.tar.bz2
cygnal-37d5841f83200da2d481d6b01c111a37acf8ca39.zip
* pinfo.h (maybe_set_exit_code_from_windows): Renamed from set_exit_state.
* pinfo.cc (pinfo::exit): Use renamed function. (proc_waiter): Ditto. Make a copy of input argument to avoid problems when procs array is shuffled. Flag when copy is made so that remove_proc knows when it is safe to reshuffle. * sigproc.cc (proc_terminate): Don't flag process_state as PID_EXITED. (remove_proc): Wait for waiter to finish copying pinfo element before moving it (an actual wait should be an extremely rare event).
Diffstat (limited to 'winsup/cygwin/sigproc.cc')
-rw-r--r--winsup/cygwin/sigproc.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index fb0680867..b99a90c87 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -65,8 +65,9 @@ Static HANDLE wait_sig_inited; // Control synchronization of
// message queue startup
Static int nprocs; // Number of deceased children
-Static char cprocs[(NPROCS + 1) * sizeof (pinfo)]; // All my deceased children info
-#define procs ((pinfo *) cprocs)
+Static char cprocs[(NPROCS + 1) * sizeof (pinfo)];// All my children info
+#define procs ((pinfo *) cprocs) // All this just to avoid expensive
+ // constructor operation at DLL startup
Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads
muto NO_COPY *sync_proc_subproc = NULL; // Control access to subproc stuff
@@ -406,8 +407,6 @@ proc_terminate (void)
for (i = 0; i < nprocs; i++)
{
procs[i]->ppid = 1;
- if (!proc_exists (procs[i]))
- procs[i]->process_state = PID_EXITED; /* CGF FIXME - still needed? */
if (procs[i].wait_thread)
{
// CloseHandle (procs[i].rd_proc_pipe);
@@ -860,7 +859,15 @@ remove_proc (int ci)
ForceCloseHandle1 (procs[ci].hProcess, childhProc);
}
if (ci < --nprocs)
- procs[ci] = procs[nprocs];
+ {
+ /* Wait for proc_waiter thread to make a copy of this element before
+ moving it or it may become confused. The chances are very high that
+ the proc_waiter thread has already done this by the time we
+ get here. */
+ while (!procs[nprocs].waiter_ready)
+ low_priority_sleep (0);
+ procs[ci] = procs[nprocs];
+ }
return 0;
}