Check out example codes for "reap zombie process in c". It will help you in understanding the concepts better.

Code Example 1

void delete_zombies(void)
{
    pid_t kidpid;
    int status;

    printf("Inside zombie deleter:  ");
    while ((kidpid = waitpid(-1, &status, WNOHANG)) > 0)
    {
         printf("Child %ld terminated\n", kidpid);
    }
    siglongjmp(env,1);
}

Learn ReactJs, React Native from akashmittal.com