From 39e5fffce8732336761c9ad43ca3812e0874eb0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Sun, 12 Jun 2016 07:12:43 +0200 Subject: sigaction should always replace the signal handler The code is confusing, there is no reason to skip setting the handler if it is already set to SIG_IGN, especially now that SIG_IGN isn't used in ratpoison. --- src/main.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/main.c b/src/main.c index e6747ef..beeac56 100644 --- a/src/main.c +++ b/src/main.c @@ -312,26 +312,13 @@ set_sig_handler (int sig, void (*action)(int)) { struct sigaction act; - /* check setting for sig */ - if (sigaction (sig, NULL, &act)) + act.sa_handler = action; + sigemptyset (&act.sa_mask); + act.sa_flags = 0; + if (sigaction (sig, &act, NULL)) { - PRINT_ERROR (("Error fetching signal handler: %s\n", strerror (errno))); - } - else - { - /* if the existing action is to ignore then leave it intact - otherwise add our handler */ - if (act.sa_handler != SIG_IGN) - { - act.sa_handler = action; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sigaction (sig, &act, NULL)) - { - PRINT_ERROR (("Error setting signal handler: %s\n", - strerror (errno))); - } - } + PRINT_ERROR (("Error setting signal handler: %s\n", + strerror (errno))); } } -- cgit v1.2.3