We don't have to reset struct sigaction
before every call to sigaction().
Use memset() to zero-initialize sigaction,
since there can be platform-specific memebers.
---
core/tarantool.c | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/core/tarantool.c b/core/tarantool.c
index e887f18..b10f76a 100644
--- a/core/tarantool.c
+++ b/core/tarantool.c
@@ -244,31 +244,22 @@ static void
signal_init(void)
{
struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_IGN;
- sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
+
if (sigaction(SIGPIPE, &sa, 0) == -1)
goto error;
sa.sa_handler = sig_int;
- sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
- if (sigaction(SIGINT, &sa, 0) == -1)
- goto error;
- sa.sa_handler = sig_int;
- sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
- if (sigaction(SIGTERM, &sa, 0) == -1)
+ if (sigaction(SIGINT, &sa, 0) == -1 ||
+ sigaction(SIGTERM, &sa, 0) == -1 ||
+ sigaction(SIGHUP, &sa, 0) == -1)
+ {
goto error;
-
- sa.sa_handler = sig_int;
- sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
- if (sigaction(SIGHUP, &sa, 0) == -1)
- goto error;
-
+ }
return;
error:
say_syserror("sigaction");
--
1.7.0.4
_______________________________________________
Mailing list: https://launchpad.net/~tarantool-developers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~tarantool-developers
More help : https://help.launchpad.net/ListHelp