AGI: Dialing multiple extensions

How can I tell, from within an AGI, which extension the Dial command connected me to – once the call is completed? I’m talking about a dial command that would look like this:

Using the plain old AGI command, it would be impossible to find out anything about the call, as the AGI loses connection with Asterisk immediatley after the Dial command completes. Even if I catch the SIGHUP or SIGTERM sent to my AGI at the end of a dial command, I can’t find out anything from Asterisk because I can’t talk to it.

I can get around this problem using DeadAGI…

So, where would I look to find out which extension answered? I’ve spend some time reading through the source for the Dial app, and I can’t discern if it is passing this information back to Asterisk in a variable – (it is logging it, so I know the information is available.

Any ideas where I should start?