ast_comparator/test/student_data/handout/shlab-handout/cases/58_tsh.c
/*
 * sigtstp_handler - The kernel sends a SIGTSTP to the shell whenever
 *     the user types ctrl-z at the keyboard. Catch it and suspend the
 *     foreground job by sending it a SIGTSTP.
 */
The kernel sends a SIGTSTP to the shell whenever
the user types ctrl-z at the keyboard. Catch it and suspend the
foreground job by sending it a SIGTSTP.
The kernel sends a SIGTSTP to the shell whenever the user types ctrl - z at the keyboard . Catch it and suspend the foreground job by sending it a SIGTSTP .
void sigtstp_handler(int sig)
{
  pid_t pid;
  struct job_t *job;
  if((pid=fgpid(jobs))>0) {
    if(kill(-pid, SIGTSTP)<0)
      unix_error("kill");
    if((job=getjobpid(jobs, pid))!=NULL) {
      job->state=ST;
      printf("Job [%i] (%i) terminated by signal %i\n", job->jid, job->pid, sig);
    }
  }
  return;
}
void sigtstp_handler ( int sig ) { pid_t pid ; struct job_t * job ; if ( ( pid = fgpid ( jobs ) ) > 0 ) { if ( kill ( - pid , SIGTSTP ) < 0 ) unix_error ( " " ) ; if ( ( job = getjobpid ( jobs , pid ) ) != NULL ) { job -> state = ST ; printf ( " \n " , job -> jid , job -> pid , sig ) ; } } return ; }
sigtstp_handler - The kernel sends a SIGTSTP to the shell whenever
     the user types ctrl-z at the keyboard.
sigtstp_handler - The kernel sends a SIGTSTP to the shell whenever the user types ctrl - z at the keyboard .
/* checks for fg process */ /* sending SIGTSTP signal to fg process group */ /* updating jobs list */