From: gumartinm Date: Tue, 18 Dec 2012 01:40:45 +0000 (+0100) Subject: Improving the set signal_handler code X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=54fcc7b9e7120ef2d66e9a98ea54dfb518613098;p=JavaTCPFork%2F.git Improving the set signal_handler code --- 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; } }