Shell Lab: trace08
This commit is contained in:
parent
d43848f722
commit
ab00d9b9ce
17
shlab/tsh.c
17
shlab/tsh.c
|
@ -325,12 +325,17 @@ void sigchld_handler(int sig)
|
|||
{
|
||||
deletejob(jobs,pid); // remove pid from job list
|
||||
}
|
||||
if (WIFSIGNALED(status))
|
||||
if (WIFSIGNALED(status)) // SIGINT, etc.
|
||||
{
|
||||
printf("Job [%d] (%d) terminated by signal %d\n", pid2jid(pid), pid, WTERMSIG(status));
|
||||
deletejob(jobs, pid);
|
||||
}
|
||||
|
||||
if (WIFSTOPPED(status)) // SIGTSTP, etc.
|
||||
{
|
||||
printf("Job [%d] (%d) stopped by signal %d\n", pid2jid(pid), pid, WSTOPSIG(status));
|
||||
struct job_t *job = getjobpid(jobs, pid);
|
||||
job->state = ST;
|
||||
}
|
||||
}
|
||||
if (pid < 0 && errno != ECHILD)
|
||||
{
|
||||
|
@ -364,6 +369,14 @@ void sigint_handler(int sig)
|
|||
*/
|
||||
void sigtstp_handler(int sig)
|
||||
{
|
||||
pid_t pid = fgpid(jobs);
|
||||
if (pid != 0)
|
||||
{
|
||||
if (kill(-pid, SIGTSTP) < 0)
|
||||
{
|
||||
unix_error("sigtstp error");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue