[LCP]wait system call
Santosh.Kawade at eyield.com
Santosh.Kawade at eyield.com
Tue Oct 30 06:25:09 UTC 2001
Hi ,
Can anybody please help me in understanding the behavior of wait system call
in following code,
pipe(pipe_fd);
strcpy(buff,"Hello World\n");
ret=fork();
switch(ret)
{
case 0:
printf(" I am the child \n");
close(pipe_fd[0]); /* close read end */
ret1=write(pipe_fd[1],buff,len);
if(ret1 != len)
{
perror(" Write failed");
return ;
}
close(pipe_fd[1]); /* close write end */
break;
case -1:
printf(" Error condition \n");
return -1 ;
default:
printf(" I am the Parent \n");
close(pipe_fd[1]);
ret1=read(pipe_fd[0],tmpbuff,sizeof(tmpbuff));
if(ret1 != len)
{
perror(" read failed");
return ;
}
close(pipe_fd[0]);
printf("\n Tmp buff contains %s",tmpbuff);
while(wait((int*)0 != ret)
printf("\n ** Parent dead \n");
break;
}
the code after in the parent process is not executed
code after while(wait((int*)0 != ret)
i.e printf("\n ** Parent dead \n"); does not print anything
More information about the linuxCprogramming
mailing list