- while ((pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)) != -1)
- for (w = childs [pid & (PID_HASHSIZE - 1)]; w; w = w->next)
- if (w->pid == pid || w->pid == -1)
- {
- w->status = status;
- event ((W)w, EV_CHILD);
- }
+ printf ("chld %x\n", revents);//D
+ if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)))
+ {
+ /* make sure we are called again until all childs have been reaped */
+ event ((W)sw, EV_SIGNAL);
+
+ child_reap (sw, pid, pid, status);
+ child_reap (sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */
+ }