Fix for previous commit

This commit is contained in:
madmaurice 2021-01-15 20:22:22 +01:00
parent dfbf2767f2
commit 78cec967b2
1 changed files with 2 additions and 2 deletions

4
main.c
View File

@ -83,13 +83,13 @@ int main(int argc, char* const* argv)
pid_child = pid;
if (sigaction(SIGTERM, &forward_signal_descriptor, NULL) == -1)
{
int err = errno;
int saved_errno = errno;
// Have to kill child here, otherwise that gets orphaned and runs anyway.
// Use SIGKILL here because it might forward SIGTERM to its child and that
// decides not to stop.
kill(pid_child, SIGKILL);
// Restore errno as it might've been overwritten by kill
errno = err;
errno = saved_errno;
err(errno, "Unable to set up signal handler in head process");
}
// parent waits for child then exits