ast_comparator/test/student_data/handout/shlab-handout/cases/36_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)
{
  siginfo_t *infop = Malloc(sizeof(siginfo_t));
  if(waitid(P_ALL, (id_t)0, infop, WEXITED | WSTOPPED | WNOHANG) == -1)
    if(errno != ECHILD)
      perror("waitid");
  deletejob(jobs, infop->si_pid);
  free(infop);
  return;
}
void sigchld_handler ( int sig ) { siginfo_t * infop = Malloc ( sizeof ( siginfo_t ) ) ; if ( waitid ( P_ALL , ( id_t ) 0 , infop , WEXITED | WSTOPPED | WNOHANG ) == -1 ) if ( errno != ECHILD ) perror ( " " ) ; deletejob ( jobs , infop -> si_pid ) ; free ( infop ) ; 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 .
/* waitid is similar to waitpid, but this function notifies
   * the pid of terminated/stopped child by filling infop structure
   */