Check if call is up from agi

What is the best way to check if a channel was hung up from agi?

If is from AGI, you can use the h, extension or hangup handlers, but I prefer AMI events. In this last case, you won’t use AGI.

I assumed they meant detecting a change half way through a script, rather than using AGI just for that purpose. Although I’ve not tried this myself, I believe SIGHUP is sent to the script on a hangup.

I am running the call flow in an agi. How can i check if the user hung up the call?

As I said, I believe you catch SIGHUP.

How does it work? how do i check for it?

If you’re a C weenie, it looks something like:

#include        <signal.h>

// trap SIGHUP -- caller hung up
        signal(SIGHUP, (void (*)(int))(long int)hangup);
        .
        .
        .
static  void                            hangup
        (
          void
        )
        {
//      syslog(LOG_ERR, "hangup detected");
        exit(EXIT_SUCCESS);
        }

There are also channel variables that control the delivery of SIGHUP. Google for ‘${AGISIGHUP}’ and ‘${AGIEXITONHANGUP}.’

The AGI command ‘channel status’ may also be of some use.

I have set ${AGIEXITONHANGUP}. to no because i still want to run after hangup but i want check a variable regularly if hangup

What is the difference of 0 and 1 in ‘channel status’?

No clue. Dive into the sources :slight_smile:

(I suspect something having to do with PSTN hardware.)

Maybe it’s just the c-weenie in me, but setting a flag in the hangup handler and then checking a simple int flag in your loop seems more efficient.

Does the hangup handler run even if the fastagi did not return yet?

Please don’t drip feed information. FastAGI can’t receive signals.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.