ast_comparator/test/student_data/handout/shlab-handout/cases/24_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;
  int jid;
  pid = fgpid(jobs);	
  jid = pid2jid(pid);	
  if(pid==0) return;	
  getjobpid(jobs, pid)->state = ST;	
  printf("Job [%d] (%d) stopped by signal %d\n", jid, pid, sig);
  kill(-pid, SIGTSTP);	
  return;
}
void sigtstp_handler ( int sig ) { pid_t pid ; int jid ; pid = fgpid ( jobs ) ; jid = pid2jid ( pid ) ; if ( pid == 0 ) return ; getjobpid ( jobs , pid ) -> state = ST ; printf ( " \n " , jid , pid , sig ) ; kill ( - pid , SIGTSTP ) ; 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 .
/* get fg process's pid */ /* get fg process's jid */ /* If there is no fg process, then return */ /* Change job state to ST */ /* Send SIGTSTP to fg process group */