I have a parent process who creates 5 child processes. Those child processes are doing something. The parent frequently ask the child processes if they are still active and they have a period of time to answer. If a certain process doesn't answer, the parent notify that the child process has dropped out. I must use signals.#include<stdio.h>#include<unistd.h>#include<signal.h>#include<string.h>#include<stdlib.h>#include<sys/types.h>#include<sys/wait.h>pid_t pid;void chandler(int signum){    psignal(signum, Signal handled \n );}void phandler(int signum, siginfo_t*siginfo, void *context){    printf(Signal received from child %d \n, siginfo->si_pid);}int main(){    int i;    int status;    struct sigaction sig;    sig.sa_handler = &chandler;    struct sigaction sig1;    sig1.sa_handler = &phandler;    sig.sa_flags = SA_SIGINFO;    sig1.sa_flags = SA_SIGINFO;    printf(Parent = %d\n, getppid());    for(i = 0; i<5; i++)    {        pid = fork();        if(pid<0){            perror(Error!);            exit(1);        }        else if(pid == 0){            sleep(3);            sigaction(SIGUSR2, &sig, NULL);            kill(getppid(), SIGUSR1);            pause();            for(;;);        }        else{            sigaction(SIGUSR1, &sig1, NULL);            if(waitpid(pid, &status, 0) > 0){                perror(waitpid);            }            else if(WIFEXITED(status) && WEXITSTATUS(status) !=0){                printf(Child was terminated!);            }        }    }    for(i = 0; i<100000; i++);    return 0;}If this the way to notify if a child has terminated? And on what condition do I have to check the waitpid() - ==1 or >0 or something else?
Parent sending signal to child and waiting for response
c;linux;child process;status monitoring;signal handling