EmbLogic's Blog

A parent having multiple childern

#include<stdio.h>
#include<sys/types.h>
int main()
{
int i,n;
pid_t pid;
printf(“enter the no of child\n”);
scanf(“%d”,&n);
pid=fork();
for(i=1;i<n;i++) { if(pid>0)
pid=fork();
}
printf(“my id is->%d and my parent id is -> %d\n”,getpid(),getppid());
return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>