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