diff -ur asterisk-1.6.1.1/apps/app_festival.c asterisk-1.6.1.1-new/apps/app_festival.c --- asterisk-1.6.1.1/apps/app_festival.c 2008-12-09 21:48:02.000000000 +0100 +++ asterisk-1.6.1.1-new/apps/app_festival.c 2009-08-05 23:50:38.654003227 +0200 @@ -128,10 +128,10 @@ if (res) { return res; } - dup2(fd, 0); - ast_close_fds_above_n(0); if (ast_opt_high_priority) ast_set_priority(0); + dup2(fd, STDIN_FILENO); + ast_close_fds_above_n(STDERR_FILENO); #ifdef __PPC__ for (x = 0; x < length; x += 2) { c = *(waveform + x + 1); @@ -140,12 +140,11 @@ } #endif - if (write(fd, waveform, length) < 0) { + if (write(STDIN_FILENO, waveform, length) < 0) { ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); } - close(fd); - exit(0); + _exit(0); } static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length, char *intkeys) @@ -188,11 +187,13 @@ /* Order is important -- there's almost always going to be mp3... we want to prioritize the user */ for (;;) { + ast_debug(1, "Block on wait\n"); res = ast_waitfor(chan, 1000); if (res < 1) { res = -1; break; } + ast_debug(1, "Read from channel\n"); f = ast_read(chan); if (!f) { ast_log(LOG_WARNING, "Null frame == hangup() detected\n"); @@ -215,6 +216,7 @@ (int)sizeof(myf.frdata) / 2, needed/2); needed = sizeof(myf.frdata); } + ast_debug(1, "Blocking on spawned read\n"); res = read(fds[0], myf.frdata, needed); if (res > 0) { myf.f.frametype = AST_FRAME_VOICE; @@ -224,6 +226,7 @@ myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.src = __PRETTY_FUNCTION__; myf.f.data.ptr = myf.frdata; + ast_debug(1, "Blocking on write\n"); if (ast_write(chan, &myf.f) < 0) { res = -1; ast_frfree(f); @@ -238,6 +241,8 @@ } else { ast_debug(1, "No more waveform\n"); res = 0; + ast_frfree(f); + break; } } ast_frfree(f);