Corretta cattiva riallocazione su linee multiple, iniziato a inserire
[gapil.git] / sources / Hand_CHLD.c
1 #include <errno.h>       /* error simbol definitions */
2 #include <signal.h>      /* signal handling declarations */
3 #include <sys/types.h>
4 #include <sys/wait.h>
5 #include "macro.h"
6
7 void Hand_CHLD(int sig)
8 {
9     int errno_save;
10     int status;
11     pid_t pid;
12     /* save errno current value */
13     errno_save = errno;
14     /* loop until no */
15     do {
16         errno = 0;
17         pid = waitpid(WAIT_ANY, &status, WNOHANG);
18         if (pid > 0) {
19             debug("child %d terminated with status %x\n", pid, status);
20         }
21     } while ((pid > 0) && (errno == EINTR));
22     /* restore errno value*/
23     errno = errno_save;
24     /* return */
25     return;
26 }