ast_comparator/test/student_data/handout/shlab-handout/cases/reference_28_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 programming assignment help 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 programming assignment help 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 programming assignment help wait for any other currently running children to terminate .
void sigchld_handler(int sig) 
{
  int stat;
  pid_t child;
  while ((child = waitpid(-1, &stat, WNOHANG | WUNTRACED)) > 0) {
    struct job_t *job = getjobpid(jobs, child);
    if (WIFSTOPPED(stat)) {
      printf("Job [%d] (%d) stopped by signal %d\n", job->jid, job->pid, WSTOPSIG(stat));
      job->state = ST;
    } else {
      if (WIFSIGNALED(stat)) {
         printf("Job [%d] (%d) terminated by signal %d\n", job->jid, job->pid, WTERMSIG(stat));
      }
      deletejob(jobs, child);
    }
  }
}
void sigchld_handler ( int sig ) { int stat ; pid_t child ; while ( ( child = waitpid ( -1 , & stat , WNOHANG | WUNTRACED ) ) > 0 ) { struct job_t * job = getjobpid ( jobs , child ) ; if ( WIFSTOPPED ( stat ) ) { printf ( " \n " , job -> jid , job -> pid , WSTOPSIG ( stat ) ) ; job -> state = ST ; } else { if ( WIFSIGNALED ( stat ) ) { printf ( " \n " , job -> jid , job -> pid , WTERMSIG ( stat ) ) ; } deletejob ( jobs , child ) ; } } }
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 .
/* check if the child is stopped or done */ /* remove the child from the job list */