summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-08-10 00:01:48 +0000
committerMark Spencer <markster@digium.com>2003-08-10 00:01:48 +0000
commit45bdf4053497d1618f4afdca82f0ec06452e2841 (patch)
tree05ca38de8843a1bb8223ac20f0db7d025bfddc7c /res
parent785958db53e1a4bb7dec2fbe289b11903959962c (diff)
Wait for mpg123 to die
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1285 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rwxr-xr-xres/res_musiconhold.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index d99d8bd49..e1ae942e7 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -574,13 +574,22 @@ static void load_moh_classes(void)
static void ast_moh_destroy(void)
{
struct mohclass *moh;
+ char buff[8192];
+ int bytes, tbytes, stime = 0;
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Destroying any remaining musiconhold processes\n");
ast_pthread_mutex_lock(&moh_lock);
moh = mohclasses;
while(moh) {
if (moh->pid) {
- kill(moh->pid, SIGKILL);
+ ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
+ stime = time(NULL);
+ kill(moh->pid, SIGABRT);
+ while (bytes = read(moh->srcfd, buff, 8192) && time(NULL) < stime + 5) {
+ tbytes = tbytes + bytes;
+ }
+ ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", moh->pid, tbytes);
+ close(moh->srcfd);
moh->pid = 0;
}
moh = moh->next;