From 679fb61d40cbbb225d8cfbe51a76d4c995742828 Mon Sep 17 00:00:00 2001 From: mwilliams Date: Fri, 21 Jun 2013 09:46:13 -0700 Subject: [PATCH] Clear g_procs before closing light processes Otherwise, the SIGCHLD handler will trigger a server shutdown. The only time this is bad is when LightProcess::Close is called from the segfault handler, because it triggers a server shutdown while we're dealing with the initial crash, which almost always leads to misleading core dumps. --- hphp/util/light_process.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hphp/util/light_process.cpp b/hphp/util/light_process.cpp index 2d81dafb1..9c62e42a6 100644 --- a/hphp/util/light_process.cpp +++ b/hphp/util/light_process.cpp @@ -423,11 +423,15 @@ bool LightProcess::initShadow(const std::string &prefix, int id, } void LightProcess::Close() { - for (int i = 0; i < g_procsCount; i++) { - g_procs[i].closeShadow(); - } + boost::scoped_array procs; + procs.swap(g_procs); + int count = g_procsCount; g_procs.reset(); g_procsCount = 0; + + for (int i = 0; i < count; i++) { + procs[i].closeShadow(); + } } void LightProcess::closeShadow() {