Merged revisions 266142 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r266142 | tilghman | 2010-05-26 16:11:44 -0500 (Wed, 26 May 2010) | 14 lines
  
  Use sigaction for signals which should persist past the initial trigger, not signal.
  
  If you call signal() in a Solaris signal handler, instead of just resetting
  the signal handler, it causes the signal to refire, because the signal is not
  marked as handled prior to the signal handler being called.  This effectively
  causes Solaris to immediately exceed the threadstack in recursive signal
  handlers and crash.
  
  (closes issue #17000)
   Reported by: rmcgilvr
   Patches: 
         20100526__issue17000.diff.txt uploaded by tilghman (license 14)
   Tested by: rmcgilvr
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@266146 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2010-05-26 21:17:46 +00:00
parent 70a1bf3142
commit fb80119b87
3 changed files with 56 additions and 30 deletions

View File

@@ -1258,14 +1258,18 @@ static void CB_RESET(void )
/*! \brief Keep track of how many threads are currently trying to wait*() on
* a child process */
static unsigned int safe_system_level = 0;
static void *safe_system_prev_handler;
static struct sigaction safe_system_prev_handler;
/*! \brief NULL handler so we can collect the child exit status */
static void null_sig_handler(int sig)
static void _null_sig_handler(int sig)
{
}
static struct sigaction null_sig_handler = {
.sa_handler = _null_sig_handler,
};
void ast_replace_sigchld(void);
void ast_replace_sigchld(void)
@@ -1275,9 +1279,9 @@ void ast_replace_sigchld(void)
level = safe_system_level++;
/* only replace the handler if it has not already been done */
if (level == 0)
safe_system_prev_handler = signal(SIGCHLD, null_sig_handler);
if (level == 0) {
sigaction(SIGCHLD, &null_sig_handler, &safe_system_prev_handler);
}
}
void ast_unreplace_sigchld(void);
@@ -1289,9 +1293,9 @@ void ast_unreplace_sigchld(void)
level = --safe_system_level;
/* only restore the handler if we are the last one */
if (level == 0)
signal(SIGCHLD, safe_system_prev_handler);
if (level == 0) {
sigaction(SIGCHLD, &safe_system_prev_handler, NULL);
}
}
int ast_safe_system(const char *s);