Fix handling of signal forwarding when running commands in a script.

We need to forward signals from a process in the same pgrp if the
pgrp leader is not either sudo or the command itself.
This commit is contained in:
Todd C. Miller
2022-11-07 14:51:41 -07:00
parent c7071f6da0
commit 36742deec3
4 changed files with 43 additions and 32 deletions

View File

@@ -282,12 +282,14 @@ mon_signal_cb(int signo, int what, void *v)
* reboot that call kill(-1, SIGTERM) to kill all other processes.
*/
if (USER_SIGNALED(sc->siginfo) && sc->siginfo->si_pid != 0) {
pid_t si_pgrp = getpgid(sc->siginfo->si_pid);
pid_t si_pgrp;
if (sc->siginfo->si_pid == mc->cmnd_pid)
debug_return;
si_pgrp = getpgid(sc->siginfo->si_pid);
if (si_pgrp != -1) {
if (si_pgrp == mc->cmnd_pgrp)
debug_return;
} else if (sc->siginfo->si_pid == mc->cmnd_pid) {
debug_return;
}
}
deliver_signal(mc, signo, false);