From 750555dfb5ec0d242184662bff7013c38e6bac2a Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 27 Jan 2005 10:14:22 +0000 Subject: [PATCH] singals patch SVN revision: 13104 --- TODO | 3 ++- src/bin/Makefile.am | 4 +++- src/bin/e_includes.h | 1 + src/bin/e_main.c | 27 +++++++++++++++++++++++++-- src/bin/e_signals.c | 23 +++++++++++++++++++++++ src/bin/e_signals.h | 6 ++++++ 6 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 src/bin/e_signals.c create mode 100644 src/bin/e_signals.h diff --git a/TODO b/TODO index 5d02539dc..3e0bee208 100644 --- a/TODO +++ b/TODO @@ -31,9 +31,10 @@ ISSUES: * clock module needs fixing to have right click menu per face * clock module should only make 1 clock per container and allow u to enable/disable that clock on that container -* same for ibar, temperature and battery modules ad for clock +* same for ibar, temperature and battery modules * pager needs 1 pager face per zone by default (optionally able to be turned off) * pager needs to be able to split off each desk in a zone it a different gadget +* pager right click menu needs to do a lot more (as with clock) * initial placement of pager and clock seems wrong (overlap deny code?) * gadman overlay deny doesnt work for edge only gadgets * gadman gadget menu needs icons :) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index cb5499fd0..a78931098 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -40,7 +40,8 @@ e_resist.h \ e_startup.h \ e_iconify.h \ e_hints.h \ -e_gadman.h +e_gadman.h \ +e_signals.h enlightenment_SOURCES = \ @@ -75,6 +76,7 @@ e_startup.c \ e_iconify.c \ e_hints.c \ e_gadman.c \ +e_signals.c \ $(ENLIGHTENMENTHEADERS) enlightenment_LDFLAGS = -export-dynamic @e_libs@ @dlopen_libs@ diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index 68b66f799..77f3ba2fd 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -28,3 +28,4 @@ #include "e_iconify.h" #include "e_hints.h" #include "e_gadman.h" +#include "e_signals.h" diff --git a/src/bin/e_main.c b/src/bin/e_main.c index fe7fec2ad..eb7af9489 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -19,6 +19,7 @@ static int _e_main_ipc_shutdown(void); static void _e_main_cb_x_fatal(void *data); static int _e_main_cb_signal_exit(void *data, int ev_type, void *ev); +static int _e_main_cb_signal_hup(void *data, int ev_type, void *ev); static int _e_main_cb_x_flusher(void *data); static int _e_main_cb_idler_before(void *data); static int _e_main_cb_idler_after(void *data); @@ -57,10 +58,17 @@ main(int argc, char **argv) int after_restart = 0; char buf[1024]; char *s; - + /* install the signal handlers. */ + struct sigaction sigsegv_action; + struct sigaction sighup_action; + sigsegv_action.sa_sigaction=&e_sigseg_act; + sigsegv_action.sa_flags=0; + sigaction(SIGSEGV, &sigsegv_action, NULL); + + /* for debugging by redirecting stdout of e to a log file to tail */ setvbuf(stdout, NULL, _IONBF, 0); - + if (getenv("NOSPLASH")) nosplash = 1; if (getenv("NOSTARTUP")) nostartup = 1; if (getenv("NOWELCOME")) nowelcome = 1; @@ -128,6 +136,12 @@ main(int argc, char **argv) "Perhaps you are out of memory?"); _e_main_shutdown(-1); } + if(!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, _e_main_cb_signal_hup, NULL)) + { + e_error_message_show("Enlightenment cannot set up a HUP signal handler.\n" + "Perhaps you are out of memory?"); + _e_main_shutdown(-1); + } /* an idle enterer to be called before all others */ _e_main_idle_enterer_before = ecore_idle_enterer_add(_e_main_cb_idler_before, NULL); @@ -785,6 +799,14 @@ _e_main_cb_signal_exit(void *data, int ev_type, void *ev) ecore_main_loop_quit(); return 1; } +static int +_e_main_cb_signal_hup(void *data, int ev_type, void *ev) +{ + /* called on SIGHUP to restart Enlightenment */ + printf("RESTART ON!\n"); + restart = 1; + ecore_main_loop_quit(); +} static int _e_main_cb_x_flusher(void *data) @@ -851,3 +873,4 @@ _e_main_cb_startup_fake_end(void *data) e_init_hide(); return 0; } + diff --git a/src/bin/e_signals.c b/src/bin/e_signals.c new file mode 100644 index 000000000..ea06693c3 --- /dev/null +++ b/src/bin/e_signals.c @@ -0,0 +1,23 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" + +/* a tricky little devil, requires e and it's libs to be built + * with the -rdynamic flag to GCC for any sort of decent output. + */ +void e_sigseg_act(int x, siginfo_t *info, void *data){ + + void *array[255]; + size_t size; + char **strings; + size_t i; + write(2, "**** SEGMENTATION FAULT ****\n", 29); + write(2, "**** Printing Backtrace... *****\n\n", 34); + size = backtrace (array, 255); + backtrace_symbols_fd(array, size, 2); + exit(-11); +} + + + diff --git a/src/bin/e_signals.h b/src/bin/e_signals.h new file mode 100644 index 000000000..6b5bf40b2 --- /dev/null +++ b/src/bin/e_signals.h @@ -0,0 +1,6 @@ +#ifndef E_SIGNALS_H +#define E_SIGNALS_H + +/* signal handler functions for e */ +void e_sigseg_act(int x, siginfo_t *info, void *data); +#endif