summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-06-12 07:12:43 +0200
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-06-12 07:12:43 +0200
commit39e5fffce8732336761c9ad43ca3812e0874eb0c (patch)
tree8810e74a0dc42742b94857ba1700b1218911607c
parent3f70fb036fc9142b4c6bf68e4bde9d7ef221aa10 (diff)
downloadratpoison-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.c25
1 files 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)));
}
}