From 8422a21d2323609df7e84d0486b4f2ee93f31635 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Fri, 2 Dec 2022 10:21:02 +0900 Subject: [PATCH] Add SIGTERM handler when the coreclr receives a sigterm, it attempts to forcibly exit without checking the thread status. As a result, there is a problem that the app-core context disappears before the mainloop. So a SIGTERM handler is added. Change-Id: I4baa3a401cbf50ed1e17d8169e48f517a8b73a17 Signed-off-by: Changgyu Choi --- tizen-cpp/app-core-cpp/CMakeLists.txt | 1 + tizen-cpp/app-core-cpp/app_core_base.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/tizen-cpp/app-core-cpp/CMakeLists.txt b/tizen-cpp/app-core-cpp/CMakeLists.txt index 81264e4..3a12ebb 100644 --- a/tizen-cpp/app-core-cpp/CMakeLists.txt +++ b/tizen-cpp/app-core-cpp/CMakeLists.txt @@ -18,6 +18,7 @@ APPLY_PKG_CONFIG(${TARGET_APP_CORE_CPP} PUBLIC BUNDLE_DEPS CAPI_SYSTEM_INFO_DEPS DLOG_DEPS + ECORE_DEPS GIO_2_DEPS SENSOR_DEPS TTRACE_DEPS diff --git a/tizen-cpp/app-core-cpp/app_core_base.cc b/tizen-cpp/app-core-cpp/app_core_base.cc index 63e5d31..03452e6 100644 --- a/tizen-cpp/app-core-cpp/app_core_base.cc +++ b/tizen-cpp/app-core-cpp/app_core_base.cc @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -1184,6 +1186,16 @@ void AppCoreBase::Init(int argc, char** argv) { impl_->loop_delegator_->OnLoopInit(argc, argv); else OnLoopInit(argc, argv); + + signal(SIGTERM, [](int n) { + ecore_main_loop_thread_safe_call_sync( + [](void* data) -> void* { + _W("sigterm handler"); + ecore_main_loop_quit(); + return nullptr; + }, nullptr); + }); + traceEnd(TTRACE_TAG_APPLICATION_MANAGER); if (impl_->feature_ & FEATURE_BACKGROUND_MANAGEMENT) -- 2.7.4