fix tty problem when enlightenment(drm-backend) is killed by SIGSEGV
authorBoram Park <boram1288.park@samsung.com>
Tue, 17 Mar 2015 13:33:55 +0000 (09:33 -0400)
committerBoram Park <boram1288.park@samsung.com>
Mon, 30 Mar 2015 03:57:38 +0000 (12:57 +0900)
Summary:
    When enlightenment is working as wayland display server, enlightenment
    changes KDSETMODE to KD_GRAPHICS in _ecore_drm_tty_setup(). However,
    when enlightenment is killed by SIGSEGV, it doesn't changes KDSETMODE
    to KD_TEXT because englightenment process doesn't call ecore_drm_tty_close().

    When enlightenment is killed by SIGSEGV, it should get drm devices with
    ecore_drm_device_get_list(), and will call ecore_drm_launcher_disconnect(),
    and ecore_drm_launcher_disconnect will call ecore_drm_tty_close() internally.

Reviewers: zmike, cedric, raster, gwanglim, devilhorns

Reviewed By: devilhorns

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2160

Change-Id: Iffe4279a50bce0cf3baf419c959bd1fef8010feb

src/bin/e_signals.c

index 5abc5d7378d6c9e8b1b514bef335237db9ffa3f4..7d2b8e22b43889b4e086f6b7676d5362ab821c1a 100644 (file)
@@ -5,16 +5,20 @@
  */
 #include "e.h"
 
+#ifdef HAVE_WAYLAND_ONLY
+#include <Ecore_Drm.h>
+#endif
+
 #ifdef HAVE_EXECINFO_H
 # include <execinfo.h>
 #endif
 
 static volatile Eina_Bool _e_x_composite_shutdown_try = 0;
 
+#ifndef HAVE_WAYLAND_ONLY
 static void
 _e_x_composite_shutdown(void)
 {
-#ifndef HAVE_WAYLAND_ONLY
 //   Ecore_X_Display *dpy;
    Ecore_X_Window root;
 
@@ -27,8 +31,8 @@ _e_x_composite_shutdown(void)
    /* ignore errors, we really don't care at this point */
    ecore_x_composite_unredirect_subwindows(root, ECORE_X_COMPOSITE_UPDATE_MANUAL);
    _e_x_composite_shutdown_try = 0;
-#endif
 }
+#endif
 
 #if 0
 #define _e_write_safe(fd, buf) _e_write_safe_int(fd, buf, sizeof(buf))
@@ -65,8 +69,23 @@ _e_write_safe_int(int fd, const char *buf, size_t size)
 EAPI void
 e_sigseg_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
 {
+#ifdef HAVE_WAYLAND_ONLY
+   Eina_List *list, *l, *ll;
+   Ecore_Drm_Device *dev;
+
+   list = ecore_drm_devices_get();
+   EINA_LIST_FOREACH_SAFE(list, l, ll, dev)
+     {
+        ecore_drm_inputs_destroy(dev);
+        ecore_drm_sprites_destroy(dev);
+        ecore_drm_device_close(dev);
+        ecore_drm_launcher_disconnect(dev);
+        ecore_drm_device_free(dev);
+     }
+
+   ecore_drm_shutdown();
+#else
    _e_x_composite_shutdown();
-#ifndef HAVE_WAYLAND_ONLY
    ecore_x_pointer_ungrab();
    ecore_x_keyboard_ungrab();
    ecore_x_ungrab();
@@ -96,8 +115,23 @@ e_sigill_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__
 EAPI void
 e_sigfpe_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
 {
+#ifdef HAVE_WAYLAND_ONLY
+   Eina_List *list, *l, *ll;
+   Ecore_Drm_Device *dev;
+
+   list = ecore_drm_devices_get();
+   EINA_LIST_FOREACH_SAFE(list, l, ll, dev)
+     {
+        ecore_drm_inputs_destroy(dev);
+        ecore_drm_sprites_destroy(dev);
+        ecore_drm_device_close(dev);
+        ecore_drm_launcher_disconnect(dev);
+        ecore_drm_device_free(dev);
+     }
+
+   ecore_drm_shutdown();
+#else
    _e_x_composite_shutdown();
-#ifndef HAVE_WAYLAND_ONLY
    ecore_x_pointer_ungrab();
    ecore_x_keyboard_ungrab();
    ecore_x_ungrab();
@@ -109,8 +143,23 @@ e_sigfpe_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__
 EAPI void
 e_sigbus_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
 {
+#ifdef HAVE_WAYLAND_ONLY
+   Eina_List *list, *l, *ll;
+   Ecore_Drm_Device *dev;
+
+   list = ecore_drm_devices_get();
+   EINA_LIST_FOREACH_SAFE(list, l, ll, dev)
+     {
+        ecore_drm_inputs_destroy(dev);
+        ecore_drm_sprites_destroy(dev);
+        ecore_drm_device_close(dev);
+        ecore_drm_launcher_disconnect(dev);
+        ecore_drm_device_free(dev);
+     }
+
+   ecore_drm_shutdown();
+#else
    _e_x_composite_shutdown();
-#ifndef HAVE_WAYLAND_ONLY
    ecore_x_pointer_ungrab();
    ecore_x_keyboard_ungrab();
    ecore_x_ungrab();
@@ -122,8 +171,23 @@ e_sigbus_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__
 EAPI void
 e_sigabrt_act(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
 {
+#ifdef HAVE_WAYLAND_ONLY
+   Eina_List *list, *l, *ll;
+   Ecore_Drm_Device *dev;
+
+   list = ecore_drm_devices_get();
+   EINA_LIST_FOREACH_SAFE(list, l, ll, dev)
+     {
+        ecore_drm_inputs_destroy(dev);
+        ecore_drm_sprites_destroy(dev);
+        ecore_drm_device_close(dev);
+        ecore_drm_launcher_disconnect(dev);
+        ecore_drm_device_free(dev);
+     }
+
+   ecore_drm_shutdown();
+#else
    _e_x_composite_shutdown();
-#ifndef HAVE_WAYLAND_ONLY
    ecore_x_pointer_ungrab();
    ecore_x_keyboard_ungrab();
    ecore_x_ungrab();