From d670858735fce93f57eb72d3b8a0bba923015d31 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Mon, 11 Dec 2006 00:52:19 +0000 Subject: 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: https://origsvn.digium.com/svn/asterisk/trunk@48376 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_nbscat.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'apps/app_nbscat.c') diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c index 60623cc93..1fb51e688 100644 --- a/apps/app_nbscat.c +++ b/apps/app_nbscat.c @@ -68,16 +68,26 @@ static int NBScatplay(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; + } + signal(SIGPIPE, SIG_DFL); + pthread_sigmask(SIG_UNBLOCK, &fullset, NULL); + if (ast_opt_high_priority) ast_set_priority(0); dup2(fd, STDOUT_FILENO); - for (x=0;x<256;x++) { + for (x = STDERR_FILENO + 1; x < 1024; x++) { if (x != STDOUT_FILENO) close(x); } @@ -85,7 +95,7 @@ static int NBScatplay(int fd) execl(NBSCAT, "nbscat8k", "-d", (char *)NULL); execl(LOCAL_NBSCAT, "nbscat8k", "-d", (char *)NULL); ast_log(LOG_WARNING, "Execute of nbscat8k failed\n"); - return -1; + _exit(0); } static int timed_read(int fd, void *data, int datalen) -- cgit v1.2.3