#include #include #include #include #include #include #include #include #define NUM_THREADS 100 void sigchld_handler(int s) { while(wait(NULL) > 0); } void *PrintHello(void *threadid) { pid_t pid; struct sigaction reapchildren; memset(&reapchildren, 0, sizeof(reapchildren)); reapchildren.sa_handler = sigchld_handler;; reapchildren.sa_flags = SA_NOCLDWAIT; if (sigaction(SIGCHLD, &reapchildren, 0) == -1) { perror("sigaction"); exit(1); } for(;;){ pid = vfork(); if(pid==0) _exit(0); } return (0); } int main (int argc, char *argv[]) { pthread_t threads[NUM_THREADS]; int rc, t; for(t=0; t