From 161edfaa008e7c44dcc8bad045095c57b17ed8f4 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 10 Jun 2001 16:00:23 +0000 Subject: [PATCH] * exceptions.cc (sigdelayed): Ensure that signal is cleared as the last operation or suffer races. * sigproc.cc (proc_subproc): Deal with zombie array overflow. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/exceptions.cc | 2 +- winsup/cygwin/sigproc.cc | 13 ++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 45df8de52..67b6e7963 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +Sun Jun 10 12:56:00 2001 Christopher Faylor + + * exceptions.cc (sigdelayed): Ensure that signal is cleared as + the last operation or suffer races. + * sigproc.cc (proc_subproc): Deal with zombie array overflow. + Sun Jun 10 11:56:00 2001 Corinna Vinschen * cygwin.din: Add fchdir symbols. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index c124b9266..82ba131c2 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1206,11 +1206,11 @@ _sigdelayed0:\n\ \n\ call _reset_signal_arrived@0\n\ pushl %5 # signal number\n\ + pushl %8 # newmask\n\ movl $0,%0 # zero the signal number as a\n\ # flag to the signal handler thread\n\ # that it is ok to set up sigsave\n\ \n\ - pushl %8\n\ call _set_process_mask@4\n\ popl %%eax\n\ jmp *%%eax\n\ diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index a44e31611..1e0c48762 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -46,6 +46,8 @@ details. */ #define no_signals_available() (!hwait_sig || !sig_loop_wait) +#define ZOMBIEMAX ((int) (sizeof (zombies) / sizeof (zombies[0]))) + /* * Global variables */ @@ -100,7 +102,7 @@ Static HANDLE wait_sig_inited = NULL; // Control synchronization of Static HANDLE events[PSIZE + 1] = {0}; // All my children's handles++ #define hchildren (events + 1) // Where the children handles begin Static pinfo pchildren[PSIZE]; // All my children info -Static pinfo zombies[PSIZE]; // All my deceased children info +Static pinfo zombies[16384]; // All my deceased children info Static int nchildren = 0; // Number of active children Static int nzombies = 0; // Number of deceased children @@ -298,8 +300,13 @@ proc_subproc (DWORD what, DWORD val) sigproc_printf ("pid %d[%d] terminated, handle %p, nchildren %d, nzombies %d", pchildren[val]->pid, val, hchildren[val], nchildren, nzombies); - zombies[nzombies] = pchildren[val]; // Add to zombie array - zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead + if (nzombies >= ZOMBIEMAX) + sigproc_printf ("Hit zombie maximum %d", nzombies); + else + { + zombies[nzombies] = pchildren[val]; // Add to zombie array + zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead + } sigproc_printf ("removing [%d], pid %d, handle %p, nchildren %d", val, pchildren[val]->pid, hchildren[val], nchildren); if ((int) val < --nchildren)