diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-18 18:52:18 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-18 18:52:18 +0000 |
commit | faa072b63aecaca5c21d607807be91d61a602179 (patch) | |
tree | bf1b62af14b44f9cfe1a3e8abcb8f0f8a7eebf5c /res | |
parent | f65397c391faf06e18ca260a9549fffec533ce66 (diff) |
Set the process group ID on the MOH process so that all children will get killed
(closes issue #14099)
Reported by: caspy
Patches:
res_musiconhold.c.patch.killpg.try2 uploaded by caspy (license 645)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@165661 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r-- | res/res_musiconhold.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 6b6c115e0..8bbf2ec67 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -485,6 +485,7 @@ static int spawn_mp3(struct mohclass *class) ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno)); _exit(1); } + setpgid(0, getpid()); if (ast_test_flag(class, MOH_CUSTOM)) { execv(argv[0], argv); } else { @@ -566,11 +567,11 @@ static void *monmp3thread(void *data) class->srcfd = -1; pthread_testcancel(); if (class->pid > 1) { - kill(class->pid, SIGHUP); + killpg(class->pid, SIGHUP); usleep(100000); - kill(class->pid, SIGTERM); + killpg(class->pid, SIGTERM); usleep(100000); - kill(class->pid, SIGKILL); + killpg(class->pid, SIGKILL); class->pid = 0; } } else @@ -1178,11 +1179,11 @@ static int ast_moh_destroy_one(struct mohclass *moh) /* Back when this was just mpg123, SIGKILL was fine. Now we need * to give the process a reason and time enough to kill off its * children. */ - kill(pid, SIGHUP); + killpg(pid, SIGHUP); usleep(100000); - kill(pid, SIGTERM); + killpg(pid, SIGTERM); usleep(100000); - kill(pid, SIGKILL); + killpg(pid, SIGKILL); while ((ast_wait_for_input(moh->srcfd, 100) > 0) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime) tbytes = tbytes + bytes; ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes); |