hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=b28c4879802f9c58462e010a5a5ff4440fcdb310

commit b28c4879802f9c58462e010a5a5ff4440fcdb310
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Mon Aug 15 17:08:10 2016 +0900

    ported crash handling for Windows OS.
---
 src/bin/main.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/bin/main.c b/src/bin/main.c
index 1b04040..5417fff 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -6,6 +6,10 @@
 #include <Eio.h>
 #include "common.h"
 
+#ifdef _WIN32
+#include <signal.h>
+#endif
+
 typedef struct app_s
 {
    Evas_Object *keygrabber;
@@ -922,7 +926,6 @@ keygrabber_init(app_data *ad)
 static Eina_Bool
 enventor_lock_create(void)
 {
-#ifndef _WIN32
    //Tempoary Folder
    const char *tmpdir = eina_environment_tmp_get();
 
@@ -969,15 +972,12 @@ enventor_lock_create(void)
 
    own_lock = EINA_TRUE;
 
-#endif
-
    return EINA_TRUE;
 }
 
 static void
 enventor_lock_remove()
 {
-#ifndef _WIN32
    //You are not the owner of the lock.
    if (!own_lock) return;
 
@@ -1006,10 +1006,28 @@ enventor_lock_remove()
      }
 
    ecore_file_remove(buf);
-#endif
 }
 
-#ifndef _WIN32
+#ifdef _WIN32
+static void
+crash_handler(int signal EINA_UNUSED)
+{
+   EINA_LOG_ERR("Eeeek! Eventor is terminated abnormally!");
+   enventor_lock_remove();
+}
+
+static void
+sigaction_setup(void)
+{
+   SignalHandlerPointer prev_handle;
+   prev_handle = signal(SIGABRT, &crash_handler);
+   prev_handle = signal(SIGFPE, &crash_handler);
+   prev_handle = signal(SIGILL, &crash_handler);
+   prev_handle = signal(SIGINT, &crash_handler);
+   prev_handle = signal(SIGSEGV, &crash_handler);
+   prev_handle = signal(SIGTERM, &crash_handler);
+}
+#else
 static void
 crash_handler(int x EINA_UNUSED, siginfo_t *info EINA_UNUSED,
               void *data EINA_UNUSED)
@@ -1017,12 +1035,10 @@ crash_handler(int x EINA_UNUSED, siginfo_t *info 
EINA_UNUSED,
    EINA_LOG_ERR("Eeeek! Eventor is terminated abnormally!");
    enventor_lock_remove();
 }
-#endif
 
 static void
 sigaction_setup(void)
 {
-#ifndef _WIN32
    //Just in case, if you are debugging using gdb,
    //you can send signals like this. "handle SIGABRT pass"
    //Use this for remove the enventor lock.
@@ -1057,9 +1073,9 @@ sigaction_setup(void)
    sigaction(SIGSTOP, &action, NULL);
 
    //Interrupt from keyboard
-//   sigaction(SIGINT, &action, NULL);
-#endif
+   //sigaction(SIGINT, &action, NULL);
 }
+#endif
 
 static Eina_Bool
 init(app_data *ad, int argc, char **argv)

-- 


Reply via email to