From: zacheiss Date: Wed, 25 Feb 2004 02:25:39 +0000 (+0000) Subject: Don't call critical_alert() from our SIGCHLD handler. It mallocs, and X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/9af63f7e0dd982e95f2887c4e8399e612d290377 Don't call critical_alert() from our SIGCHLD handler. It mallocs, and we can deadlock if the daemon is in the middle of a malloc() when it receives the signal. --- diff --git a/server/mr_main.c b/server/mr_main.c index 08b76128..1b90b849 100644 --- a/server/mr_main.c +++ b/server/mr_main.c @@ -48,6 +48,8 @@ client **clients; int nclients, clientssize; int dormant; +int child_exited_abnormally = 0; +int child_pid, child_signal, child_status; void reapchild(int x); void godormant(int x); @@ -212,6 +214,14 @@ int main(int argc, char **argv) if (takedown) break; + + if (child_exited_abnormally) + { + critical_alert("moirad", "%d: child exits with signal %d status %d", + child_pid, child_signal, child_status); + child_exited_abnormally = 0; + } + time(&now); if (!inc_running || now - inc_started > INC_TIMEOUT) next_incremental(); @@ -371,8 +381,10 @@ void reapchild(int x) inc_running = 0; if (!takedown && (WTERMSIG(status) != 0 || WEXITSTATUS(status) != 0)) { - critical_alert("moirad", "%d: child exits with signal %d status %d", - pid, WTERMSIG(status), WEXITSTATUS(status)); + child_exited_abnormally = 1; + child_pid = pid; + child_signal = WTERMSIG(status); + child_status = WEXITSTATUS(status); } } }