diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2016-06-12 07:12:43 +0200 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2016-06-12 07:12:43 +0200 |
commit | 39e5fffce8732336761c9ad43ca3812e0874eb0c (patch) | |
tree | 8810e74a0dc42742b94857ba1700b1218911607c | |
parent | 3f70fb036fc9142b4c6bf68e4bde9d7ef221aa10 (diff) | |
download | ratpoison-39e5fffce8732336761c9ad43ca3812e0874eb0c.zip |
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.
-rw-r--r-- | src/main.c | 25 |
1 files changed, 6 insertions, 19 deletions
@@ -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))); } } |