[Libreoffice-commits] online.git: loolwsd/LOOLBroker.cpp
Henry Castro
hcastro at collabora.com
Fri Jan 8 19:38:17 PST 2016
loolwsd/LOOLBroker.cpp | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
New commits:
commit f3735f145f31ce1f706e3ba9fec5b2b9206c1ec0
Author: Henry Castro <hcastro at collabora.com>
Date: Fri Jan 8 23:34:34 2016 -0400
loolwsd: force kills a child with abnormal state.
diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 5fdd28b..4718182 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -573,6 +573,24 @@ static int startupLibreOfficeKit(const bool sharePages, const int nLOKits,
return pId;
}
+
+static bool waitForTerminationChild(const Process::PID aPID)
+{
+ int status;
+ short nCntr = 3;
+
+ while (nCntr-- > 0)
+ {
+ waitpid(aPID, &status, WUNTRACED | WNOHANG);
+ if (WIFEXITED(status))
+ break;
+
+ sleep(MAINTENANCE_INTERVAL);
+ }
+
+ return nCntr;
+}
+
// Broker process
int main(int argc, char** argv)
{
@@ -862,8 +880,13 @@ int main(int argc, char** argv)
for (auto i : _childProcesses)
{
Log::info("Requesting child process " + std::to_string(i.first) + " to terminate.");
- Process::requestTermination(i.first);
close(i.second);
+ Process::requestTermination(i.first);
+ if (!waitForTerminationChild(i.first))
+ {
+ Log::info("Forcing a child process " + std::to_string(i.first) + " to terminate.");
+ Process::kill(i.first);
+ }
}
aPipe.join();
More information about the Libreoffice-commits
mailing list