Summary:ASTERISK-00014: asterisk leaves zombie mpg123
Reporter:dcarr (dcarr)Labels:
Date Opened:2003-07-26 16:25:48Date Closed:2004-09-25 02:40:14
Versions:Frequency of
Environment:Attachments:( 0) moh.diff
( 1) moh-new.diff
Description:Every time I run asterisk it spawns 2 mpg123 processes. However, when I issue a restart command from the asterisk cli it only kills the 2nd mpg123 and leaves the 1st mpg123 process as a zombie.


This is extremely reproducible. I performed 5 restarts and by recording the mpg123 PIDs each time it was easy to tell asterisk was killing the 2nd process but leaving the 1st process running.
Comments:By: sbingner (sbingner) 2003-07-26 19:54:42

I have made a patch for this that seems to work... unless of course * does not shut down cleanly.   It may not be the best way to do it, but it works.


By: dcarr (dcarr) 2003-07-26 20:33:07

I applied the patch and it compiled fine. It didn't fix the behavior though.

By: John Laur (gork) 2003-07-27 00:42:39

I was wondering -- why does moh call mpg123 when asterisk has a builtin mp3 codec? This may be along the lines of the other bug requesting moh to handle other formats besides mp3..

By: sbingner (sbingner) 2003-07-27 08:27:53

It will not fix the problem if * is not properly shut down... but if shutdown now, shutdown when convenient or service asterisk stop is executed, it should.  I just tested another few times on my system and it always killed it properly.

I agree, it should use the builtin codec IMHO... That's covered in JerJer's http://bugs.digium.com/bug_view_page.php?bug_id=0000020

By: Jared Smith (jsmith) 2003-07-27 17:15:28

The problem is NOT that asterisk wasn't properly shutdown.  This happens consistently on a "restart when convenient".  Also, I'm curious what causes asterisk spawn X processes of mpg123 on startup.  At work our server spawns two mpg123 processes on a server with 72 Zap channels.  At home, it spawns 6 mpg123 processes with only 24 Zap channels.  If asterisk were made to only spawn one, I think the existing code would shut it down fine.

By: sbingner (sbingner) 2003-07-27 21:17:57

I see, it seems that ast_moh_destroy isn't called when asterisk is restarted, only when it is stopped... rather * just closes the filehandle or something.  It dosn't kill either process with restart.

By: Ricardo Villa (ricvil) 2003-08-03 18:05:41

I seem to have a problem related to this issue as well.  When Asterisk starts I see 2 instances of mpg123 running.  When I do a "stop now" it kills only one instance.  But the big problem is that the console gets filled up with this message:
"Ouch ... error while writing audio data: : Broken pipe"

It only goes away when I kill the other instance of mpg123 manually.  I hope this can get fixed.


By: Ricardo Villa (ricvil) 2003-08-03 18:20:34

I applied the patch and it now kills both instances of mpg123 when I issue the "stop now".  It is working properly now then.


By: dcarr (dcarr) 2003-08-04 13:00:45

It does NOT work when you issue the "restart now" or "restart when convenient" commands.

By: Mark Spencer (markster) 2003-08-09 14:31:57

Even with latest CVS?  Can you see it try to kill them?

By: sbingner (sbingner) 2003-08-09 15:45:32

I updated my patch to work with new changes, looks like it'll properly kill on restart as well as stop now :)

PS: do you need that fax from me authorizing you to be able to apply this to CVS?  I thought I sent it but I can't recall


With my patch

[root@agiel asterisk]# ps ax | grep mpg
10398 pts/1    S      0:00 /usr/bin/mpg123
10399 pts/1    S      0:00 /usr/bin/mpg123
10425 pts/0    S      0:00 grep mpg

agiel*CLI> restart when convenient
Disconnected from Asterisk server

[root@agiel asterisk]# ps ax | grep mpg
10437 pts/1    S      0:00 /usr/bin/mpg123
10445 pts/1    S      0:00 /usr/bin/mpg123
10451 pts/0    S      0:00 grep mpg

w/o my patch

[root@agiel res]# ps ax | grep mpg
10686 pts/1    S      0:01 /usr/bin/mpg123
10690 pts/1    S      0:00 /usr/bin/mpg123
10703 pts/0    S      0:00 grep mpg

agiel*CLI> restart when convenient
Disconnected from Asterisk server
Ouch ... error while writing audio data: : Broken pipe
Ouch ... error while writing audio data: : Broken pipe

[root@agiel res]# ps ax | grep mpg
10690 pts/1    S      0:02 /usr/bin/mpg123
10707 pts/1    S      0:00 /usr/bin/mpg123
10722 pts/1    S      0:00 /usr/bin/mpg123

By: Mark Spencer (markster) 2003-08-09 18:54:32

Yes, please.  I'll go ahead and apply it since it's relatively minor