On Friday 14 Feb 2014, Jerry Geis wrote:> I believe I am running an AGI (to put users in a conf) before the
> confbridge is built. So the users are not really get in the conf...
>
> exten X,1,run agi to put users in conf
> exten X,n,ConfBridge()
>
> How do I have in the dial plan ConfBridge() and someplace
> run an AGI that brings the users I want into that Conf.
>
> I cannot delay in the AGI and wait for the conf because
> the conf is not built until I return from the AGI...
>
> Any thoughts?
>
> Thanks,
>
> Jerry
Make your AGI script fork itself; have the child process detach, and the
parent process exit. Then, the AGI call will return quickly to the dialplan;
and meanwhile, the script can continue in the background at its own leisure.
Example code (Perl) follows:
#!/usr/bin/perl -w
use strict;
use Asterisk::AGI;
my $child_pid;
my $AGI = new Asterisk::AGI;
my %params = $AGI->ReadParse();
$SIG{CHLD} = "IGNORE";
if ($child_pid = fork) {
# This is executed in the parent process
exit;
}
elsif (defined $child_pid) {
# This is executed in the child process
close STDIN;
close STDOUT;
close STDERR;
# Now we are detached
#
# This is where we do the funky stuff
#
exit;
}
else {
# Oh, s#!t
die "Could not fork: $!";
};
# We should never, ever get here
exit;
--
AJS
Answers come *after* questions.