diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-11 00:47:21 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-11 00:47:21 +0000 |
commit | 5d5b0ca48b0d770e792cde1fedb041f4c759426e (patch) | |
tree | 21af91d1593e4a3a2f2cfd366b1b2914d3ad3bbd /apps/app_mp3.c | |
parent | 8b2c905a6c6adbeac57d717fea391beec10c5e3d (diff) |
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/branches/1.4@48375 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_mp3.c')
-rw-r--r-- | apps/app_mp3.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/app_mp3.c b/apps/app_mp3.c index 667de67ad..55d50f011 100644 --- a/apps/app_mp3.c +++ b/apps/app_mp3.c @@ -64,15 +64,25 @@ static int mp3play(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; + } if (ast_opt_high_priority) ast_set_priority(0); + signal(SIGPIPE, SIG_DFL); + pthread_sigmask(SIG_UNBLOCK, &fullset, NULL); + dup2(fd, STDOUT_FILENO); - for (x=0;x<256;x++) { + for (x=STDERR_FILENO + 1;x<256;x++) { if (x != STDOUT_FILENO) close(x); } @@ -94,7 +104,7 @@ static int mp3play(char *filename, int fd) execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); } ast_log(LOG_WARNING, "Execute of mpg123 failed\n"); - return -1; + _exit(0); } static int timed_read(int fd, void *data, int datalen, int timeout) |