+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
_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;}
_pinfo *child;
int clearing;
waitq *w;
+ int thiszombie;
+ _pinfo *zombie_proc = NULL;
#define wval ((waitq *) 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",
/* 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);
}
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");
}