#include <dlfcn.h>
+#include <signal.h>
#include <string>
#include <fstream>
}
}
+struct sigaction sig_abrt_new;
+struct sigaction sig_abrt_old;
+
+static bool checkOnSigabrt = false;
+static void onSigabrt(int signum)
+{
+ fprintf(stderr, "onSigabrt is called!!!\n");
+
+ if (checkOnSigabrt) {
+ fprintf(stderr, "SIGABRT is already handled. Go to exit\n");
+ exit(0);
+ }
+
+ if (hasException()) {
+ fprintf(stderr, "Unhandled exception is occured. Ignore coredump creation and terminate normally\n");
+ exit(0);
+ } else {
+ fprintf(stderr, "SIGABRT from native. raise(%d)\n", signum);
+ checkOnSigabrt = true;
+ if (sigaction(SIGABRT, &sig_abrt_old, NULL) == 0) {
+ if (raise(signum) < 0) {
+ fprintf(stderr, "Fail to raise SIGABRT\n");
+ }
+ } else {
+ fprintf(stderr, "Fail to set original SIGABRT handler\n");
+ }
+ }
+}
+
+static void registerSigHandler()
+{
+ sig_abrt_new.sa_handler = onSigabrt;
+ if (sigemptyset(&sig_abrt_new.sa_mask) == 0) {
+ _ERR("Fail to initialize signal set");
+ }
+
+ if (sigaction(SIGABRT, &sig_abrt_new, &sig_abrt_old) < 0) {
+ _ERR("Fail to add sig handler");
+ }
+}
+
CoreRuntime::CoreRuntime(const char* mode) :
initializeClr(nullptr),
executeAssembly(nullptr),
_ERR("Failed to redirect FD");
return -1;
}
+
+ registerSigHandler();
}
pluginSetAppInfo(appId, path);