From 54fcc7b9e7120ef2d66e9a98ea54dfb518613098 Mon Sep 17 00:00:00 2001 From: gumartinm Date: Tue, 18 Dec 2012 02:40:45 +0100 Subject: [PATCH] Improving the set signal_handler code --- Daemon/javafork.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Daemon/javafork.c b/Daemon/javafork.c index ff6abc3..9494800 100644 --- a/Daemon/javafork.c +++ b/Daemon/javafork.c @@ -124,12 +124,19 @@ int main (int argc, char *argv[]) * As seen on http://www.gnu.org/software/libc/manual/html_node/Initial-Signal-Actions.html#Initial-Signal-Actions */ memset (&sa, 0, sizeof(sa)); - sigaction (SIGINT, NULL, &sa); + if (sigaction (SIGINT, NULL, &sa) < 0) { + syslog (LOG_ERR, "SIGINT retrieve current signal handler failed: %m"); + return 1; + } if (sa.sa_handler != SIG_IGN) { sa.sa_handler = &sigint_handler; - sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + if (sigemptyset(&sa.sa_mask) < 0) { + syslog (LOG_ERR, "SIGINT empty mask: %m"); + return 1; + } if (sigaction(SIGINT, &sa, NULL) < 0) { - syslog (LOG_ERR, "SIGINT signal handler failed: %m"); + syslog (LOG_ERR, "SIGINT set signal handler failed: %m"); return 1; } } -- 2.1.4