/* Test Script to check the Usage of coninously initiating the applicable amount of child processes. Note : The total count of child processes has been hardcoded to 10,000 It is supposed to be changed accordingly. */ #include #include #include #include #include #include #include #include long int vproc = 0; void _forkproc( ) { pid_t p_id; if(vproc == 10000) { printf("Done"); _exit(0); } printf("\n Inside fork procedure"); p_id = vfork(); if(p_id == 0) { vproc++; printf("\n\n Initiated Child Process :%d %d",vproc,getpid()); _forkproc(); _exit(0); } } int main(int argc,char *argv[]) { pid_t pid,_pid; int i,num; while(1) { pid = vfork(); if(pid == 0) { printf("\n\n Inside the Process initiated by the vfork : Test 1 Pass "); _forkproc(); printf("\n\n Exiting vfork child processes"); } else if(_pid == -1) printf("\n\n Error :> -pid generated return value -1 : Test Failure"); else if(pid != -1) { printf("\n\n Initiated a Parent Process with pid : %d",getpid()); } else if(pid == -1) printf("Error:> Test failure "); } return(0); }