PARENT AND CHILD PROCESS ID PROGRAM
#include “ sys/types.h “
#include “ sys/stat.h “
main()
{
int p1,p2,p3,p4,p5;
p1=getpid();
system("clear");
printf("\n process 1=%d\n",p1);
p2=fork();
if(p2==0)
{
p1=wait();
printf("parent process 2=%d\n",getpid());
printf("\n process 2=%d\n",getpid());
p3=fork();
p1=wait();
if(p3==0)
{
printf("\n parent process 3=%d\n",getpid());
printf("\nprocess 3=%d\n",getpid());
p4=fork();
if(p4==0)
{
p3=wait();
printf("\n parent process 4=%d\n",getppid());
printf("\n process 4=%d\n",getpid());
}
if(p4 “ 0)
{
p4=wait();
p3=wait();
p5=fork();
if(p5==0)
{
printf("\nparent process 5=%d\n",getppid());
printf("\nprocess 5=%d\n",getpid());
}
}
}
}
}
Thursday, February 4, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment