aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-16 19:35:57 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-16 19:35:57 +0000
commit4bf7193cef559bb170f5d37a91d12eaad2b0eeae (patch)
tree5b67dcc12a1581000951ba767f36a4fccb9959e3 /res
parent00a179b1bdf0c5b4e9c782ae352b798b6c28e7db (diff)
Improve child process reaping (bug #278)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1521 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-xres/res_musiconhold.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 3dc78fba0..3dccd4eb3 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -94,17 +94,10 @@ static struct mohclass *mohclasses;
static ast_mutex_t moh_lock = AST_MUTEX_INITIALIZER;
+#define LOCAL_MPG_123 "/usr/local/bin/mpg123"
#define MPG_123 "/usr/bin/mpg123"
#define MAX_MP3S 256
-static void child_handler(int sig)
-{
- int status;
- if (wait4(-1,&status, WNOHANG, NULL)<1)
- if (option_debug)
- ast_log(LOG_DEBUG, "Huh? Child handler, but nobody there?\n");
-}
-
static int spawn_mp3(struct mohclass *class)
{
int fds[2];
@@ -121,7 +114,7 @@ static int spawn_mp3(struct mohclass *class)
ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir);
return -1;
}
- argv[0] = MPG_123;
+ argv[0] = "mpg123";
argv[1] = "-q";
argv[2] = "-s";
argv[3] = "--mono";
@@ -190,7 +183,12 @@ static int spawn_mp3(struct mohclass *class)
close(x);
/* Child */
chdir(class->dir);
+ /* Default install is /usr/local/bin */
+ execv(LOCAL_MPG_123, argv);
+ /* Many places have it in /usr/bin */
execv(MPG_123, argv);
+ /* Check PATH as a last-ditch effort */
+ execvp("mpg123", argv);
ast_log(LOG_WARNING, "Exec failed: %s\n", strerror(errno));
exit(1);
} else {
@@ -220,7 +218,6 @@ static void *monmp3thread(void *data)
tv.tv_usec = 0;
error_sec = 0;
error_usec = 0;
- signal(SIGCHLD, child_handler);
for(;/* ever */;) {
/* Spawn mp3 player if it's not there */
if (class->srcfd < 0) {