summaryrefslogtreecommitdiff
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-12-18 18:54:47 +0000
committerRussell Bryant <russell@russellbryant.com>2008-12-18 18:54:47 +0000
commit8cc50d467719c2031df5ed52f33798f9ce5487be (patch)
tree1a3d129d52d8dff7978d55a809746c5a36343ca0 /res/res_musiconhold.c
parent665b55e6f899075eff32f496ef6bea5fe8853551 (diff)
Merged revisions 165661 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r165661 | russell | 2008-12-18 12:52:18 -0600 (Thu, 18 Dec 2008) | 7 lines 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: https://origsvn.digium.com/svn/asterisk/trunk@165662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 091a6a5b8..d2a6f9f7e 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -516,6 +516,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 {
@@ -597,11 +598,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 {
@@ -1465,11 +1466,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) < stop_time)
tbytes = tbytes + bytes;
ast_debug(1, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);