ast_comparator/test/student_data/handout/shlab-handout/cases/reference_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) 
{
    int i;
    int jobindex = -1;
    for (i = 0; i < MAXJOBS; i++) 
    {
	if (jobs[i].state == FG) 
	{
	  jobindex = i;
	  break;
	}
    }
    if(jobindex <0)
    {
      return;
    }
    int foregroundpid = jobs[jobindex].pid;
    jobs[jobindex].state = ST;
    printf("Job [%d] (%d) stopped by signal %d\n", jobs[jobindex].jid, jobs[jobindex].pid,sig);
    kill(foregroundpid,SIGTSTP);
}
void sigtstp_handler ( int sig ) { int i ; int jobindex = -1 ; for ( i = 0 ; i < MAXJOBS ; i ++ ) { if ( jobs [ i ] . state == FG ) { jobindex = i ; break ; } } if ( jobindex < 0 ) { return ; } int foregroundpid = jobs [ jobindex ] . pid ; jobs [ jobindex ] . state = ST ; printf ( " \n " , jobs [ jobindex ] . jid , jobs [ jobindex ] . pid , sig ) ; kill ( foregroundpid , SIGTSTP ) ; }
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 .
//Find foregeround job //Do nothing //Get pid from jobs list entry //Send to forground job //Record new state