[LCP]wait, waitpid - help

Greg Black gjb at gbch.net
Wed Feb 20 15:56:15 UTC 2002


"Srinath" wrote:

| This is a multi-part message in MIME format.

Please don't do this -- plain text is the right choice.

| the following is a handler for SIGCHLD signal in a program.
| this function was written to prevent zombies and to terminate the=20
| child by catching the SIGCHLD.
| 
| void sig_chld()
| {
|   pid_t pid;
|   int stat;
| 
|  pid=wait(&stat);
|  printf("child %d terminated \n",pid);
|  return ;
| }

The behaviour of this handler is undefined because it calls
printf() -- read any decent Unix programming text for the
explanation.

For the answers to the rest of your questions, read the relevant
documentation which describes those calls.  If the "&stat" has
you puzzled, read an introductory text about C.

If you have questions *after* doing your reading, come back here
with some more details.



More information about the linuxCprogramming mailing list