--- asterisk-1.6.2.7.orig/res/res_agi.c 2010-03-25 15:21:51.000000000 +0000 +++ asterisk-1.6.2.7/res/res_agi.c 2010-05-25 17:13:46.000000000 +0000 @@ -2937,8 +2937,8 @@ if (!buf[0]) { /* Program terminated */ - if (returnstatus) { - returnstatus = -1; + if (returnstatus != AGI_RESULT_HANGUP && returnstatus != AGI_RESULT_SUCCESS) { + returnstatus = AGI_RESULT_FAILURE; } ast_verb(3, "<%s>AGI Script %s completed, returning %d\n", chan->name, request, returnstatus); if (pid > 0)