aboutsummaryrefslogtreecommitdiffstats
path: root/asterisk.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-16 19:35:57 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-16 19:35:57 +0000
commit4bf7193cef559bb170f5d37a91d12eaad2b0eeae (patch)
tree5b67dcc12a1581000951ba767f36a4fccb9959e3 /asterisk.c
parent00a179b1bdf0c5b4e9c782ae352b798b6c28e7db (diff)
Improve child process reaping (bug #278)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1521 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rwxr-xr-xasterisk.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/asterisk.c b/asterisk.c
index 88c5f01ce..d8a6563e0 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -337,11 +337,19 @@ static void hup_handler(int num)
ast_module_reload();
}
-
-static void pipe_handler(int num)
+static void child_handler(int sig)
{
- /* Ignore sigpipe */
+ int n, status;
+
+ /*
+ * Reap all dead children -- not just one
+ */
+ for (n = 0; wait4(-1, &status, WNOHANG, NULL) > 0; n++)
+ ;
+ if (n == 0 && option_debug)
+ ast_log(LOG_DEBUG, "Huh? Child handler, but nobody there?\n");
}
+
static void set_title(char *text)
{
/* Set an X-term or screen title */
@@ -1366,11 +1374,14 @@ int main(int argc, char *argv[])
}
if (option_console && !option_verbose)
ast_verbose("[ Booting...");
+
signal(SIGURG, urg_handler);
signal(SIGINT, __quit_handler);
signal(SIGTERM, __quit_handler);
signal(SIGHUP, hup_handler);
- signal(SIGPIPE, pipe_handler);
+ signal(SIGCHLD, child_handler);
+ signal(SIGPIPE, SIG_IGN);
+
if (set_priority(option_highpriority)) {
printf(term_quit());
exit(1);