ast_comparator/test/student_data/handout/shlab-handout/cases/42_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 jobidx;
	pid_t fpid;
	sigset_t prev_all, mask_one;
	Sigaddset(&mask_one, SIGCHLD);
	if((fpid = fgpid(jobs)) == 0) {
		printf("There is no foreground job\n");
		return;
	}
	Kill(-fpid, SIGINT);	
	jobidx = pid2jid(fpid);
	Sigprocmask(SIG_BLOCK, &mask_one, &prev_all);
	Deletejob(jobs, fpid); 
	Sigprocmask(SIG_SETMASK, &prev_all, NULL);
	printf("Job [%d] (%d) terminatd by signal 2\n", jobidx, fpid);
	return;
}
void sigint_handler ( int sig ) { int jobidx ; pid_t fpid ; sigset_t prev_all , mask_one ; Sigaddset ( & mask_one , SIGCHLD ) ; if ( ( fpid = fgpid ( jobs ) ) == 0 ) { printf ( " \n " ) ; return ; } Kill ( - fpid , SIGINT ) ; jobidx = pid2jid ( fpid ) ; Sigprocmask ( SIG_BLOCK , & mask_one , & prev_all ) ; Deletejob ( jobs , fpid ) ; Sigprocmask ( SIG_SETMASK , & prev_all , NULL ) ; printf ( " \n " , jobidx , fpid ) ; 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 .
/* Send SIGINT to foreground job process */ /* delete job from the list */