Shell Lab: trace07
This commit is contained in:
parent
1d8b5a6f9c
commit
d43848f722
|
@ -347,9 +347,12 @@ void sigchld_handler(int sig)
|
||||||
void sigint_handler(int sig)
|
void sigint_handler(int sig)
|
||||||
{
|
{
|
||||||
pid_t pid = fgpid(jobs); // get pid of foreground job
|
pid_t pid = fgpid(jobs); // get pid of foreground job
|
||||||
if (kill(-pid, SIGINT) < 0) // try to send SIGINT
|
if (pid != 0) // if no foreground job (PID=0), do nothing (ONLY send to foreground)
|
||||||
{
|
{
|
||||||
unix_error("sigint error"); // failed
|
if (kill(-pid, SIGINT) < 0) // try to send SIGINT
|
||||||
|
{
|
||||||
|
unix_error("sigint error"); // failed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue