cleanup zombies during run, and check processes still exist
authorAndrew Tridgell <tridge@samba.org>
Thu, 31 Jul 2008 11:13:08 +0000 (21:13 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 31 Jul 2008 11:13:08 +0000 (21:13 +1000)
tsm_torture.c

index 8f3659e..846e641 100644 (file)
@@ -498,6 +498,9 @@ static void sig_alarm(int sig)
        }
 
        for (i=0;i<options.nprocesses;i++) {
+               if (kill(children[i].pid, 0) != 0) {
+                       continue;
+               }
                total += children[i].count - children[i].lastcount;
                children[i].lastcount = children[i].count;              
                total_online += children[i].online_count;
@@ -676,7 +679,7 @@ int main(int argc, char * const argv[])
 
        /* wait for the children to finish */
        for (i=0;i<options.nprocesses;i++) {
-               while (waitpid(children[i].pid, 0, 0) != 0 && errno != ECHILD) ;
+               while (waitpid(-1, 0, 0) != 0 && errno != ECHILD) ;
        }       
 
        return 0;