2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2008 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 SignalHandler(int sig)
32 static int loop_count = 0;
35 Mode.wm.in_signal_handler = 1;
37 if (EDebug(EDBUG_TYPE_SESSION))
38 Eprintf("SignalHandler signal=%d\n", sig);
43 SessionExit(EEXIT_RESTART, NULL);
51 SessionExit(EEXIT_EXIT, NULL);
61 Alert(_("Enlightenment performed an Illegal Instruction.\n" "\n"
62 "This most likely is due to you having installed an run a\n"
63 "binary of Enlightenment that was compiled for a make or model\n"
64 "of CPU not 100%% identical or compatible with yours. Please\n"
65 "either obtain the correct package for your system, or\n"
66 "re-compile Enlightenment and possibly any support libraries\n"
67 "that you got in binary format to run Enlightenment.\n"));
71 Alert(_("Enlightenment caused a Floating Point Exception.\n" "\n"
72 "This means that Enlightenment or support library routines it calls\n"
73 "have performed an illegal mathematical operation (most likely\n"
74 "dividing a number by zero). This is most likely a bug. It is\n"
75 "recommended to restart now. If you wish to help fix this please\n"
76 "compile Enlightenment with debugging symbols in and run\n"
77 "Enlightenment under gdb so you can backtrace for where it died and\n"
78 "send in a useful bug report with backtrace information and variable\n"
83 Alert(_("Enlightenment caused Segment Violation (Segfault)\n" "\n"
84 "This means that Enlightenment or support library routines it calls\n"
85 "have accessed areas of your system's memory that they are not\n"
86 "allowed access to. This is most likely a bug. It is recommended to\n"
87 "restart now. If you wish to help fix this please compile\n"
88 "Enlightenment with debugging symbols in and run Enlightenment\n"
89 "under gdb so you can backtrace for where it died and send in a\n"
90 "useful bug report with backtrace information and variable\n"
95 Alert(_("Enlightenment caused Bus Error.\n" "\n"
96 "It is suggested you check your hardware and OS installation.\n"
97 "It is highly unusual to cause Bus Errors on operational\n"
105 #if 0 /* Avoid X-ops? */
108 Mode.wm.exit_now = 1;
109 SessionExit(EEXIT_ERROR, NULL);
114 while (waitpid(-1, &status, WNOHANG) > 0)
119 Mode.wm.in_signal_handler = 0;
123 doSignalsSetup(int setup)
125 static const int signals[] = {
126 SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE,
127 SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGCHLD, SIGBUS
133 * We may be here after a fork/exec within in a signal handler.
134 * Therefore, lets just clear the blocked signals.
136 sigemptyset(&sa.sa_mask);
137 sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) NULL);
139 for (i = 0; i < sizeof(signals) / sizeof(int); i++)
142 if (Mode.wm.coredump &&
143 (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS))
148 sa.sa_handler = SignalHandler;
149 sa.sa_flags = (sig == SIGCHLD) ? SA_RESTART : 0;
153 sa.sa_handler = SIG_DFL;
156 sigemptyset(&sa.sa_mask);
157 sigaction(sig, &sa, (struct sigaction *)0);
164 /* This function will set up all the signal handlers for E */
171 /* This function will restore all the signal handlers for E */