diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-11 00:52:19 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-11 00:52:19 +0000 |
commit | 8b92ed8dd27369b93a641a8a89c0812082ca312a (patch) | |
tree | 80cfa0cd4517050b2e78379b2f2710141f333d79 /apps/app_zapras.c | |
parent | 9fee33efd24e42dd7d72d9133c744cc01a4d8e8c (diff) |
Merged revisions 48375 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r48375 | tilghman | 2006-12-10 18:47:21 -0600 (Sun, 10 Dec 2006) | 13 lines
Merged revisions 48374 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48374 | tilghman | 2006-12-10 18:33:59 -0600 (Sun, 10 Dec 2006) | 5 lines
When doing a fork() and exec(), two problems existed (Issue 8086):
1) Ignored signals stayed ignored after the exec().
2) Signals could possibly fire between the fork() and exec(), causing Asterisk
signal handlers within the child to execute, which caused nasty race conditions.
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48376 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_zapras.c')
-rw-r--r-- | apps/app_zapras.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/apps/app_zapras.c b/apps/app_zapras.c index 9e841603c..7b85f7040 100644 --- a/apps/app_zapras.c +++ b/apps/app_zapras.c @@ -82,11 +82,23 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args) char *argv[PPP_MAX_ARGS]; int argc = 0; char *stringp=NULL; + sigset_t fullset, oldset; + + sigfillset(&fullset); + pthread_sigmask(SIG_BLOCK, &fullset, &oldset); /* Start by forking */ pid = fork(); - if (pid) + if (pid) { + pthread_sigmask(SIG_SETMASK, &oldset, NULL); return pid; + } + + /* Restore original signal handlers */ + for (x=0;x<NSIG;x++) + signal(x, SIG_DFL); + + pthread_sigmask(SIG_UNBLOCK, &fullset, NULL); /* Execute RAS on File handles */ dup2(chan->fds[0], STDIN_FILENO); @@ -99,10 +111,6 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args) for (x=STDERR_FILENO + 1;x<1024;x++) close(x); - /* Restore original signal handlers */ - for (x=0;x<NSIG;x++) - signal(x, SIG_DFL); - /* Reset all arguments */ memset(argv, 0, sizeof(argv)); |