From 8534be076c73603d58d54634b5d3e78bd5d96ec0 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 28 Sep 2022 14:33:16 +1000 Subject: 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 Signed-off-by: Stefano Brivio --- passt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'passt.c') diff --git a/passt.c b/passt.c index f0ed897..4796c89 100644 --- a/passt.c +++ b/passt.c @@ -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"; -- cgit v1.2.3