|Summary:||ASTERISK-20532: AGI script fork()s, Asterisk doesn't keep processing the dialplan when parent dies|
|Reporter:||Omri Bahumi (omri)||Labels:|
|Date Opened:||2012-10-08 14:57:44||Date Closed:||2012-11-27 17:36:16.000-0600|
|Environment:||Debian 6 64bits||Attachments:||( 0) agi_problematic.py|
( 1) agi_workaround.py
|Description:||When an AGI script forks, Asterisk won't keep processing the dialplan when the parent dies.|
By looking at the AGI code I've noticed it waits for an EOF on the stdout file descriptor, and not for the process to die.
Attached two Python AGI scripts (uses pyst-0.4.38).
Problematic example: you'll notice the dialplan stops processing until both the parent and child exit (hence closing stdout fd).
Workaround example: the execution continues when the parent exits and the child closes stdout, not waiting for the entire script execution to terminate.
|Comments:||By: Rusty Newton (rnewton) 2012-10-10 15:50:31.298-0500|
Please provide the exact version of Asterisk you are using as well. Thanks!
By: Omri Bahumi (omri) 2012-10-10 17:51:47.712-0500
There was no 188.8.131.52 on the version list, that's why I didn't mention it.
By: Matt Jordan (mjordan) 2012-10-18 10:49:57.100-0500
184.108.40.206 is a minor rev of 220.127.116.11. It would only contain a regression fix or a security fix.
By: Rusty Newton (rnewton) 2012-11-06 18:21:03.876-0600
Omri, as far as I can tell this isn't a bug.
Your work around is appropriate and would be the suggested resolution. Right now, Asterisk expects that your script close the connection for dialplan execution to continue. We would consider the report a suggestion for improvement.
Can you provide a patch for the improvement? Otherwise, as per the [issue guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines#AsteriskIssueGuidelines-Howtorequestafeature] we'll go ahead and close out the issue, and wait for you or someone else to reopen the report with a patch included.
By: Jonathan Harris (lardconcepts) 2017-07-01 02:12:24.778-0500
Oh wow - thank you Omri for finding this fix and I'm SO glad Marcello on the mailing list pointed me towards this. I struggled for about 6 hours in total looking for a way to async some AGI, finally to be told to use fork in python, and it didn't work as expected.
Well, if this isn't a bug, then "behaviour which differs dramatically from that which is expected" would definitely be the tag.
This fix works for me and needs to be laser-etched into the first page about everything ever written about AGI! THanks.