Add SIGTERM handler
[platform/core/appfw/app-core.git] / tizen-cpp / app-core-cpp / app_core_base.cc
index 63e5d31..03452e6 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <Ecore.h>
 #include <aul.h>
 #include <aul_app_lifecycle.h>
 #include <aul_watchdog.h>
@@ -27,6 +28,7 @@
 #include <locale.h>
 #include <malloc.h>
 #include <sensor_internal.h>
+#include <signal.h>
 #include <stdbool.h>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -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)