aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_ices.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-11 00:33:59 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-11 00:33:59 +0000
commit5125deb3148e6711a6855de8430c4958ed77eaa1 (patch)
tree578d53d159454cd798b99b22d066995d4760791b /apps/app_ices.c
parent8f132ae7cbf665bfc3e4385a5a9588b83bf06921 (diff)
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/branches/1.2@48374 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_ices.c')
-rw-r--r--apps/app_ices.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/apps/app_ices.c b/apps/app_ices.c
index b6b5ad3f7..5a9b9412d 100644
--- a/apps/app_ices.c
+++ b/apps/app_ices.c
@@ -68,15 +68,27 @@ static int icesencode(char *filename, int fd)
{
int res;
int x;
+ sigset_t fullset, oldset;
+
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
res = fork();
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
- if (res)
+ if (res) {
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
+ }
+
+ /* Stop ignoring PIPE */
+ signal(SIGPIPE, SIG_DFL);
+ pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
+
if (option_highpriority)
ast_set_priority(0);
dup2(fd, STDIN_FILENO);
- for (x=STDERR_FILENO + 1;x<256;x++) {
+ for (x=STDERR_FILENO + 1;x<1024;x++) {
if ((x != STDIN_FILENO) && (x != STDOUT_FILENO))
close(x);
}
@@ -87,7 +99,7 @@ static int icesencode(char *filename, int fd)
/* As a last-ditch effort, try to use PATH */
execlp("ices", "ices", filename, (char *)NULL);
ast_log(LOG_WARNING, "Execute of ices failed\n");
- return -1;
+ _exit(0);
}
static int ices_exec(struct ast_channel *chan, void *data)