[LCP]wait, waitpid - help

Srinath redindian at nettaxi.com
Wed Feb 20 15:39:09 UTC 2002


Hello All,

the following is a handler for SIGCHLD signal in a program.
this function was written to prevent zombies and to terminate the 
child by catching the SIGCHLD.

void sig_chld()
{
  pid_t pid;
  int stat;

 pid=wait(&stat);
 printf("child %d terminated \n",pid);
 return ; 
}

now, i want to know what happens when  " pid=wait(&stat) " statement
executes. how the child terminates (without becoming a zombie) . what is 
the significance of "&stat ".
also in case of waitpid(-1,&stat, WNOHNG) --what happens here


Thanks 
Srinath
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/linuxcprogramming/attachments/20020220/76405b7d/attachment.htm 


More information about the linuxCprogramming mailing list