1
0
mirror of https://passt.top/passt synced 2024-12-22 21:55:22 +00:00

Catch failures when installing signal handlers

Stop ignoring the return codes from sigaction() and signal().  Unlikely to
happen in practice, but if it ever did it could lead to really hard to
debug problems.  So, take clang-tidy's advice and check for errors here.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2022-09-28 14:33:16 +10:00 committed by Stefano Brivio
parent 8a19f36864
commit 8534be076c

View File

@ -201,8 +201,10 @@ int main(int argc, char **argv)
name = basename(argv0);
if (strstr(name, "pasta")) {
sa.sa_handler = pasta_child_handler;
sigaction(SIGCHLD, &sa, NULL);
signal(SIGPIPE, SIG_IGN);
if (sigaction(SIGCHLD, &sa, NULL) || signal(SIGPIPE, SIG_IGN)) {
err("Couldn't install signal handlers");
exit(EXIT_FAILURE);
}
c.mode = MODE_PASTA;
log_name = "pasta";