mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
res_agi.c: Ensure SIGCHLD handler functions are properly balanced.
Calls to `ast_replace_sigchld()` and `ast_unreplace_sigchld()` must be
balanced to ensure that we can capture the exit status of child
processes when we need to. This extends to functions that call
`ast_replace_sigchld()` and `ast_unreplace_sigchld()` such as
`ast_safe_fork()` and `ast_safe_fork_cleanup()`.
The primary change here is ensuring that we do not call
`ast_safe_fork_cleanup()` in `res_agi.c` if we have not previously
called `ast_safe_fork()`.
Additionally we reinforce some of the documentation and add an
assertion to, ideally, catch this sooner were this to happen again.
Fixes #922
(cherry picked from commit 750333ae03
)
This commit is contained in:
committed by
Asterisk Development Team
parent
2e3879a609
commit
06d8aac6fd
@@ -1118,6 +1118,10 @@ void ast_unreplace_sigchld(void)
|
||||
unsigned int level;
|
||||
|
||||
ast_mutex_lock(&safe_system_lock);
|
||||
|
||||
/* Wrapping around here is an error */
|
||||
ast_assert(safe_system_level > 0);
|
||||
|
||||
level = --safe_system_level;
|
||||
|
||||
/* only restore the handler if we are the last one */
|
||||
|
Reference in New Issue
Block a user