ast_comparator/test/student_data/handout/shlab-handout/cases/45_tsh.c
/*
 * sigchld_handler - The kernel sends a SIGCHLD to the shell whenever
 *     a child job terminates (becomes a zombie), or stops because it
 *     received a SIGSTOP or SIGTSTP signal. The handler reaps all
 *     available zombie children, but doesn't wait for any other
 *     currently running children to terminate.
 */
The kernel sends a SIGCHLD to the shell whenever
a child job terminates (becomes a zombie), or stops because it
received a SIGSTOP or SIGTSTP signal. The handler reaps all
available zombie children, but doesn't wait for any other
currently running children to terminate.
The kernel sends a SIGCHLD to the shell whenever a child job terminates ( becomes a zombie ) or stops because it received a SIGSTOP or SIGTSTP signal . The handler reaps all available zombie children but doesn ' t wait for any other currently running children to terminate .
void sigchld_handler(int sig)
{
    pid_t pid;
    int status;
    while ((pid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) {
        if (WIFSTOPPED(status)) {
            sigtstp_handler(-SIGTSTP);
        } else if (WIFSIGNALED(status)){
            sigint_handler(-SIGINT);
        } else {
            deletejob(jobs, pid);
        }
    }
    return;
}
void sigchld_handler ( int sig ) { pid_t pid ; int status ; while ( ( pid = waitpid ( -1 , & status , WNOHANG | WUNTRACED ) ) > 0 ) { if ( WIFSTOPPED ( status ) ) { sigtstp_handler ( - SIGTSTP ) ; } else if ( WIFSIGNALED ( status ) ) { sigint_handler ( - SIGINT ) ; } else { deletejob ( jobs , pid ) ; } } return ; }
sigchld_handler - The kernel sends a SIGCHLD to the shell whenever
     a child job terminates (becomes a zombie), or stops because it
     received a SIGSTOP or SIGTSTP signal.
sigchld_handler - The kernel sends a SIGCHLD to the shell whenever a child job terminates ( becomes a zombie ) or stops because it received a SIGSTOP or SIGTSTP signal .
// negative value to identify whether to print or not // negative value to identify whether to print or not