/MY PROGRAM ARE COMPILED IN FEDORA15 ..WITH 4.6 gcc compiler...../
/*IMPLEMENTATION OF PROGRAM SHOWING FUNCTIONING OF FORK IN FOR LOOP..*/ //LETS DO SOME MANIPULATION IN IT...TRY TO KILL CHILD PROCESS EVERY TIME..BY ONE WAY OR OTHER..KILL? //SHOWED IN NEXT FILE #include<stdio.h> #include<stdlib.h> #include<fcntl.h> #include<unistd.h> #include<string.h> int main() { int i,ret; for(i=0;i<3;i++) { printf("ANU\n"); ret=fork();//now in this loop...when i=0;;;fork is called ..creates parent & child;;;after closing elsefor other two times of loop...its child that has been created in 1st fork will also act as parent...& ofcourse there will be parent of all also...now for 2nd time fork...one more child is created ...this child will also play as parent for 3rd time of loop..bcz of close of else loop...sooo..all the childs created will also act like parents for other times of loop left....bigger child that has been created 1st will be finished 1st..& so on...... if(ret==0) { printf("in child father=%d self=%d\n",getppid(),getpid()); } else { printf("in parent self=%d\n",getpid()); } } return 0; }