From 8288d5fcc25134724e6a84b7140541c54618e36d Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 16 May 2023 22:58:26 +0200 Subject: [PATCH] bridge: ignore SIGTERM signal when running as child client Signed-off-by: falkTX --- source/bridges-plugin/CarlaBridgePlugin.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/bridges-plugin/CarlaBridgePlugin.cpp b/source/bridges-plugin/CarlaBridgePlugin.cpp index 9085eb815..cbf79ebf1 100644 --- a/source/bridges-plugin/CarlaBridgePlugin.cpp +++ b/source/bridges-plugin/CarlaBridgePlugin.cpp @@ -72,13 +72,14 @@ using water::String; // ------------------------------------------------------------------------- static bool gIsInitiated = false; -static volatile bool gCloseNow = false; +static volatile bool gCloseBridge = false; +static volatile bool gCloseSignal = false; static volatile bool gSaveNow = false; #if defined(CARLA_OS_UNIX) static void closeSignalHandler(int) noexcept { - gCloseNow = true; + gCloseSignal = true; } static void saveSignalHandler(int) noexcept { @@ -89,7 +90,7 @@ static BOOL WINAPI winSignalHandler(DWORD dwCtrlType) noexcept { if (dwCtrlType == CTRL_C_EVENT) { - gCloseNow = true; + gCloseSignal = true; return TRUE; } return FALSE; @@ -229,7 +230,7 @@ public: gIsInitiated = true; #if defined(USING_JUCE) && (defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)) - CarlaJUCE::setupAndUseMainApplication(gIdle, &gCloseNow); + CarlaJUCE::setupAndUseMainApplication(gIdle, &gCloseSignal); #else int64_t timeToEnd = 0; @@ -239,7 +240,7 @@ public: fEngine->transportPlay(); } - for (; runMainLoopOnce() && ! gCloseNow;) + for (; runMainLoopOnce() && ! gCloseBridge;) { gIdle(); # if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) @@ -250,6 +251,8 @@ public: # endif if (testing && timeToEnd - water::Time::currentTimeMillis() < 0) break; + if (gCloseSignal && ! fUsingBridge) + break; } #endif @@ -270,12 +273,12 @@ protected: case ENGINE_CALLBACK_ENGINE_STOPPED: case ENGINE_CALLBACK_PLUGIN_REMOVED: case ENGINE_CALLBACK_QUIT: - gCloseNow = true; + gCloseBridge = gCloseSignal = true; break; case ENGINE_CALLBACK_UI_STATE_CHANGED: if (gIsInitiated && value1 != 1 && ! fUsingBridge) - gCloseNow = true; + gCloseBridge = gCloseSignal = true; break; default: