ast_comparator/test/student_data/handout/shlab-handout/cases/reference_24_tsh.c
/* 
 * sigint_handler - The kernel sends a SIGINT to the shell whenver the
 *    user types ctrl-c at the keyboard.  Catch it and send it along
 *    to the foreground job.  
 */
The kernel sends a SIGINT to the shell whenver the
user types ctrl-c at the keyboard.  Catch it and send it along
to the foreground job.
The kernel sends a SIGINT to the shell whenver the user types ctrl - c at the keyboard . Catch it and send it along to the foreground job .
void sigint_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)
    {
      printf("Exiting Shell.\n");      
      exit(0);
    }
    int foregroundpid = jobs[jobindex].pid;
    printf("Job [%d] (%d) terminated by signal %d\n", jobs[jobindex].jid, jobs[jobindex].pid,sig);
    kill(foregroundpid,SIGINT);  
    return;
}
void sigint_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 ) { printf ( " \n " ) ; exit ( 0 ) ; } int foregroundpid = jobs [ jobindex ] . pid ; printf ( " \n " , jobs [ jobindex ] . jid , jobs [ jobindex ] . pid , sig ) ; kill ( foregroundpid , SIGINT ) ; return ; }
sigint_handler - The kernel sends a SIGINT to the shell whenver the
    user types ctrl-c at the keyboard.
sigint_handler - The kernel sends a SIGINT to the shell whenver the user types ctrl - c at the keyboard .
//Find foregeround job //Could not find job in list that is foreground //Exit the program //Get pid from jobs list entry //Send to forground job