From 291d498bf8faacdfbf661f1ec59a550a05817178 Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 3 Jun 2008 09:15:11 +0000 Subject: [PATCH] Use the SA_RESETHAND flag to sigaction() Instead of resetting the signal handler back to SIG_DFL on our own, this is now done automatically for us by the kernel! git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1083 726aef4b-f618-498e-8847-2d620e286838 --- main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 67f7e413..103ed364 100644 --- a/main.cpp +++ b/main.cpp @@ -39,8 +39,6 @@ static void GenerateHelp(const char *appname) { } static void die(int sig) { - signal(SIGSEGV, SIG_DFL); - signal(SIGABRT, SIG_DFL); signal(SIGPIPE, SIG_DFL); #ifdef _DEBUG @@ -246,6 +244,12 @@ int main(int argc, char** argv) { sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, (struct sigaction*) NULL); + sa.sa_handler = rehash; + sigaction(SIGHUP, &sa, (struct sigaction*) NULL); + + // Once this signal is caught, the signal handler is reset + // to SIG_DFL. This avoids endless loop with signals. + sa.sa_flags = SA_RESETHAND; sa.sa_handler = die; sigaction(SIGINT, &sa, (struct sigaction*) NULL); sigaction(SIGILL, &sa, (struct sigaction*) NULL); @@ -254,9 +258,6 @@ int main(int argc, char** argv) { sigaction(SIGSEGV, &sa, (struct sigaction*) NULL); sigaction(SIGTERM, &sa, (struct sigaction*) NULL); - sa.sa_handler = rehash; - sigaction(SIGHUP, &sa, (struct sigaction*) NULL); - int iRet = 0; try {