Thursday, April 12, 2012

Chain of Process


#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{
  int i;
  int n=10;

  pid_t childpid;

  for(i=1;i<n;++i)
   if(childpid=fork())
   break;

 printf("this is process %ld with parent %ld\n",(long)getpid(),(long)getppid());

}

No comments:

Post a Comment