]> sourceware.org Git - newlib-cygwin.git/commitdiff
* pinfo.h (pinfo::operator ==): Add a way to check for _pinfo types.
authorChristopher Faylor <me@cgf.cx>
Wed, 17 Dec 2003 22:47:32 +0000 (22:47 +0000)
committerChristopher Faylor <me@cgf.cx>
Wed, 17 Dec 2003 22:47:32 +0000 (22:47 +0000)
* sigproc.cc (proc_subproc): Ensure that zombie is removed when SIGCHLD ==
SIG_IGN but still allow wait()ing threads to wake up.

winsup/cygwin/ChangeLog
winsup/cygwin/exceptions.cc
winsup/cygwin/pinfo.h
winsup/cygwin/sigproc.cc
winsup/cygwin/wait.cc

index 291d4ac44a201a9a1dbb8fa452966fd04222ef6e..e44dd1ed38fde8acddb6cc3b502ed30afc4de86f 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-17  Christopher Faylor  <cgf@redhat.com>
+
+       * pinfo.h (pinfo::operator ==): Add a way to check for _pinfo types.
+       * sigproc.cc (proc_subproc): Ensure that zombie is removed when SIGCHLD
+       == SIG_IGN but still allow wait()ing threads to wake up.
+
 2003-12-16  Christopher Faylor  <cgf@redhat.com>
 
        * exceptions.cc (set_signal_mask): Report on input argument rather than
index 341ae732fb48f1d1085e4de9a050913cd585635c..ffa6d4d3bd2ac10b58d8f0746739fbea209032e9 100644 (file)
@@ -792,7 +792,7 @@ signal_fixup_after_fork ()
 extern "C" void __stdcall
 set_sig_errno (int e)
 {
-  set_errno (e);
+  *_my_tls.errno_addr = e;
   _my_tls.saved_errno = e;
   // sigproc_printf ("errno %d", e);
 }
index 279556371c9afcb1d767efeb9f61d6923f2f8141..b0ddb67023faf190bc57d3001247050d92b2f8e3 100644 (file)
@@ -144,6 +144,7 @@ public:
   _pinfo *operator -> () const {return procinfo;}
   int operator == (pinfo *x) const {return x->procinfo == procinfo;}
   int operator == (pinfo &x) const {return x.procinfo == procinfo;}
+  int operator == (_pinfo *x) const {return x == procinfo;}
   int operator == (void *x) const {return procinfo == x;}
   int operator == (int x) const {return (int) procinfo == (int) x;}
   int operator == (char *x) const {return (char *) procinfo == x;}
index 5150e54dff18e465f29fc0ac2862f52171c34a21..78e45e67f2fb12ee4626bcc6b867f5a5d0db33d4 100644 (file)
@@ -304,6 +304,8 @@ proc_subproc (DWORD what, DWORD val)
   _pinfo *child;
   int clearing;
   waitq *w;
+  int thiszombie;
+  _pinfo *zombie_proc = NULL;
 
 #define wval    ((waitq *) val)
 
@@ -375,9 +377,8 @@ 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);
 
-      int thiszombie;
       thiszombie = nzombies;
-      zombies[nzombies] = pchildren[val];      // Add to zombie array
+      zombie_proc = zombies[nzombies] = pchildren[val];        // Add to zombie array
       zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
 
       sigproc_printf ("zombifying [%d], pid %d, handle %p, nchildren %d",
@@ -391,11 +392,11 @@ proc_subproc (DWORD what, DWORD val)
       /* See if we should care about the this terminated process.  If we've
         filled up our table or if we're ignoring SIGCHLD, then we immediately
         remove the process and move on. Otherwise, this process becomes a zombie
-        which must be reaped by a wait() call. */
-      if (nzombies >= NZOMBIES
-         || global_sigs[SIGCHLD].sa_handler == (void *) SIG_IGN)
+        which must be reaped by a wait() call.  FIXME:  This is a very inelegant
+        way to deal with this and could lead to process hangs.  */
+      if (nzombies >= NZOMBIES)
        {
-         sigproc_printf ("automatically removing zombie %d", thiszombie);
+         sigproc_printf ("zombie table overflow %d", thiszombie);
          remove_zombie (thiszombie);
        }
 
@@ -477,6 +478,10 @@ proc_subproc (DWORD what, DWORD val)
        sigproc_printf ("finished processing terminated/stopped child");
       else
        {
+         if (zombie_proc && zombies[thiszombie]
+             && zombies[thiszombie] == zombie_proc
+             && global_sigs[SIGCHLD].sa_handler == (void *) SIG_IGN)
+           remove_zombie (thiszombie);
          waitq_head.next = NULL;
          sigproc_printf ("finished clearing");
        }
index d3c3416ee4ec4c67e0a910b9a123bde2a726425f..d7dd1f82efe3e8d65781bf18349797ce24979520 100644 (file)
@@ -98,8 +98,8 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
 
       if (w->status == -1)
        {
-         call_signal_handler_now ();
          set_sig_errno (EINTR);
+         call_signal_handler_now ();
          sawsig = true;
          res = -1;
        }
This page took 0.042543 seconds and 5 git commands to generate.