#include <errno.h>
#include <execinfo.h>
#include <gio/gio.h>
+#include <glib-unix.h>
#include <glib.h>
#include <libintl.h>
#include <linux/limits.h>
#include <locale.h>
#include <malloc.h>
#include <sensor_internal.h>
-#include <signal.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/time.h>
int feature_ = 0;
IAppCore* core_delegator_ = nullptr;
IMainLoop* loop_delegator_ = nullptr;
+ guint signal_handler_source_ = 0;
};
AppCoreBase::EventBase::EventBase(Type type)
else
OnLoopInit(argc, argv);
- signal(SIGTERM, [](int n) {
- _W("sigterm handler");
- if (context_ != nullptr)
- context_->Exit();
- });
+ impl_->signal_handler_source_ = g_unix_signal_add(SIGTERM,
+ [](gpointer data) -> gboolean {
+ _W("sigterm handler");
+ if (context_ != nullptr) {
+ context_->Exit();
+ context_->impl_->signal_handler_source_ = 0;
+ }
+
+ return G_SOURCE_REMOVE;
+ }, nullptr);
+
+ if (impl_->signal_handler_source_ == 0)
+ _E("Failed to add sigterm handler.");
traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
}
void AppCoreBase::Fini() {
+ if (impl_->signal_handler_source_) {
+ g_source_remove(impl_->signal_handler_source_);
+ impl_->signal_handler_source_ = 0;
+ }
+
Dispose();
}