diff --git a/res/res_agi.c b/res/res_agi.c index 005f1878cdd48945c95ac81acc9b517956d7554b..686b17ddd29a877a5d0ebd0a262067017e10eb25 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1869,7 +1869,8 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi returnstatus = -1; if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "AGI Script %s completed, returning %d\n", request, returnstatus); - waitpid(pid, status, 0); + if (pid > 0) + waitpid(pid, status, 0); /* No need to kill the pid anymore, since they closed us */ pid = -1; break;