ast_comparator/test/student_data/handout/shlab-handout/cases/reference_32_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) {
printf("stop sig\n");
pid_t pid = fgpid(jobs); 
int jid = pid2jid(pid);
if (pid != 0) {
printf("Job [%d] (%d) stopped by signal %d/n", jid, pid, sig);
(*(getjobpid(jobs, pid))).state = ST; 
send_signal(-pid, sig); 
}
return;
}
void sigtstp_handler ( int sig ) { printf ( " \n " ) ; pid_t pid = fgpid ( jobs ) ; int jid = pid2jid ( pid ) ; if ( pid != 0 ) { printf ( " " , jid , pid , sig ) ; ( * ( getjobpid ( jobs , pid ) ) ) . state = ST ; send_signal ( - pid , sig ) ; } 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 .
/* get pid of the fg job */ /* if there is a fg job, send it the signal */ /* job's state is "stopped" */ /* forward the signal to the process group */