From: Tilghman Lesher Date: Mon, 27 Jun 2011 16:30:50 +0000 (+0000) Subject: Save and restore errno from within signal handlers. X-Git-Tag: 1.8.5-rc1~7^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72d041e1b93813cdf3fad31a26b74eaff1433bc6;p=thirdparty%2Fasterisk.git Save and restore errno from within signal handlers. This is recommended by the POSIX standard, as well as by the sigaction(2) manpage for various platforms that we support (e.g. Mac OS X). git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@324955 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/asterisk.c b/main/asterisk.c index beba0679c5..5609fb99f9 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1479,7 +1479,7 @@ static struct sigaction urg_handler = { static void _hup_handler(int num) { - int a = 0; + int a = 0, save_errno = errno; if (option_verbose > 1) printf("Received HUP signal -- Reloading configs\n"); if (restartnow) @@ -1490,6 +1490,7 @@ static void _hup_handler(int num) fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno)); } } + errno = save_errno; } static struct sigaction hup_handler = { @@ -1500,7 +1501,7 @@ static struct sigaction hup_handler = { static void _child_handler(int sig) { /* Must not ever ast_log or ast_verbose within signal handler */ - int n, status; + int n, status, save_errno = errno; /* * Reap all dead children -- not just one @@ -1509,6 +1510,7 @@ static void _child_handler(int sig) ; if (n == 0 && option_debug) printf("Huh? Child handler, but nobody there?\n"); + errno = save_errno; } static struct sigaction child_handler = {