[asterisk-commits] tilghman: branch 1.8 r324955 - /branches/1.8/main/asterisk.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 27 11:30:53 CDT 2011


Author: tilghman
Date: Mon Jun 27 11:30:50 2011
New Revision: 324955

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=324955
Log:
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).

Modified:
    branches/1.8/main/asterisk.c

Modified: branches/1.8/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/asterisk.c?view=diff&rev=324955&r1=324954&r2=324955
==============================================================================
--- branches/1.8/main/asterisk.c (original)
+++ branches/1.8/main/asterisk.c Mon Jun 27 11:30:50 2011
@@ -1479,7 +1479,7 @@
 
 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 @@
 			fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
 		}
 	}
+	errno = save_errno;
 }
 
 static struct sigaction hup_handler = {
@@ -1500,7 +1501,7 @@
 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 @@
 		;
 	if (n == 0 && option_debug)	
 		printf("Huh?  Child handler, but nobody there?\n");
+	errno = save_errno;
 }
 
 static struct sigaction child_handler = {




More information about the asterisk-commits mailing list