Add the ability to retrieve the exit code of the forked AGI process. If there

is an error executing the AGI script, or the AGI script itself returns a
non-zero value, the AGISTATUS variable will now be set to FAILURE instead of
SUCCESS.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@30328 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2006-05-25 18:31:19 +00:00
parent 35d729fb40
commit 238cdb249f
3 changed files with 61 additions and 19 deletions

View File

@@ -608,21 +608,15 @@ static void null_sig_handler(int signal)
}
AST_MUTEX_DEFINE_STATIC(safe_system_lock);
/*! Keep track of how many threads are currently trying to wait*() on
* a child process */
static unsigned int safe_system_level = 0;
static void *safe_system_prev_handler;
int ast_safe_system(const char *s)
void ast_replace_sigchld(void)
{
pid_t pid;
int x;
int res;
struct rusage rusage;
int status;
unsigned int level;
/* keep track of how many ast_safe_system() functions
are running at this moment
*/
ast_mutex_lock(&safe_system_lock);
level = safe_system_level++;
@@ -631,6 +625,31 @@ int ast_safe_system(const char *s)
safe_system_prev_handler = signal(SIGCHLD, null_sig_handler);
ast_mutex_unlock(&safe_system_lock);
}
void ast_unreplace_sigchld(void)
{
unsigned int level;
ast_mutex_lock(&safe_system_lock);
level = --safe_system_level;
/* only restore the handler if we are the last one */
if (level == 0)
signal(SIGCHLD, safe_system_prev_handler);
ast_mutex_unlock(&safe_system_lock);
}
int ast_safe_system(const char *s)
{
pid_t pid;
int x;
int res;
struct rusage rusage;
int status;
ast_replace_sigchld();
pid = fork();
@@ -656,14 +675,7 @@ int ast_safe_system(const char *s)
res = -1;
}
ast_mutex_lock(&safe_system_lock);
level = --safe_system_level;
/* only restore the handler if we are the last one */
if (level == 0)
signal(SIGCHLD, safe_system_prev_handler);
ast_mutex_unlock(&safe_system_lock);
ast_unreplace_sigchld();
return res;
}