From 0f9bd80ca27db7aec057dbd494df60e3dc003a11 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Tue, 15 Nov 2016 21:57:41 -0500 Subject: [PATCH] loolwsd: set ShutdownFlag only with SIGINT The logic is to use ShutdownFlag only in WSD to initiate graceful shut down while saving documents. When CTRL+C is hit WSD, forkit, and kits get SIGINT, but only WSD should handle ShutdownFlag. Others are signaled internally by WSD to terminate using SIGTERM. The second CTRL+C on WSD will flag TerminationFlag for more aggressive shutdown. This is logged on every subsequent signal and not just the first. Furthermore, any other signal to WSD should terminate more aggressively, so no reason to set ShutdownFlag in those cases. Change-Id: I10fa38fe85925da1020983f897cc6cdbbd2623f8 Reviewed-on: https://gerrit.libreoffice.org/30887 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian --- loolwsd/common/SigUtil.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/loolwsd/common/SigUtil.cpp b/loolwsd/common/SigUtil.cpp index f3e7f032a..793177600 100644 --- a/loolwsd/common/SigUtil.cpp +++ b/loolwsd/common/SigUtil.cpp @@ -119,17 +119,15 @@ namespace SigUtil static void handleTerminationSignal(const int signal) { - if (!ShutdownFlag) + if (!ShutdownFlag && signal == SIGINT) { Log::signalLogPrefix(); Log::signalLog(" Shutdown signal received: "); Log::signalLog(signalName(signal)); Log::signalLog("\n"); ShutdownFlag = true; - return; } - - if (!TerminationFlag) + else { Log::signalLogPrefix(); Log::signalLog(" Forced-Termination signal received: ");