head 1.1;
access;
symbols;
locks
ashish:1.1; strict;
comment @ * @;
1.1
date 2015.03.24.13.44.13; author ashish; state Exp;
branches;
next ;
desc
@programme for orphan condition where the child terminates after the termination of parents,
where the child beacme the orphan
@
1.1
log
@Initial revision
@
text
@#include
#include
#include
#include
int main()
{
char *lines;
int n;
pid_t pid;
printf(“its starting\n”);
pid=fork();
printf(“pid->%d\n”,pid);
switch(pid)
{
case -1: printf (“error\n”);
break;
case 0: lines=”mmm child”;
printf(“child id is:%d\t %d\n”,getpid(),getppid());
n=7;
break;
//its orphan state because here child s going to be terminate after the parent….so the child would be orphan here..//
default: lines=”mm parent”;
printf(“parent id is :%d\n”,getppid());
n=5;
break;
}
for(;n>0;n–)
{
puts(lines);
printf(“%s:my id:%d \t my parent pid is %d\n”,lines,getpid(),getppid());
//sleep(1);
}//child became orphan and it will terminate with pid of init process//
exit(0);
}
@