ast_comparator/test/student_data/handout/shlab-handout/cases/45_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)
{
    pid_t pid = fgpid(jobs);
    if (pid != 0) {
        if (kill(-pid, SIGINT) < 0 ) {
            if (errno != ESRCH) {
                unix_error("kill error");
            }
        }
        if (sig < 0) {
            printf("Job [%d] (%d) terminated by signal %d\n", pid2jid(pid), pid, -sig);
            deletejob(jobs, pid);
        }
    }
    return;
}
void sigint_handler ( int sig ) { pid_t pid = fgpid ( jobs ) ; if ( pid != 0 ) { if ( kill ( - pid , SIGINT ) < 0 ) { if ( errno != ESRCH ) { unix_error ( " " ) ; } } if ( sig < 0 ) { printf ( " \n " , pid2jid ( pid ) , pid , - sig ) ; deletejob ( jobs , pid ) ; } } 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 .