2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
32 static char rcsid[] = "$XConsortium: WmSignal.c /main/6 1996/10/17 16:20:07 drk $"
36 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
42 #include "WmGlobal.h" /* This should be the first include */
47 * include extern functions
50 #include "WmFeedback.h"
51 #include "WmFunction.h"
55 * Function Declarations:
68 /*************************************<->*************************************
70 * AbortWmSignalHandler ()
75 * This function is called on receipt of a fatal signal. We reset
76 * the keyboard focus to pointer root before aborting.
78 *************************************<->***********************************/
80 AbortWmSignalHandler (int sig)
85 * Set input focus back to pointer root
87 XSetInputFocus(DISPLAY, PointerRoot, RevertToPointerRoot, CurrentTime);
88 XSync (DISPLAY, False);
89 XCloseDisplay (DISPLAY);
92 * Invoke the default handler
94 (void) sigemptyset(&sa.sa_mask);
96 sa.sa_handler = SIG_DFL;
97 (void) sigaction (sig, &sa, (struct sigaction *) 0);
101 } /* END OF FUNCTION AbortSignalHandler */
104 /*************************************<->*************************************
106 * RestoreDefaultSignalHandlers ()
111 * This function sets up the signal handlers for the window manager.
113 *************************************<->***********************************/
116 RestoreDefaultSignalHandlers (void)
119 struct sigaction osa;
122 * Restore default action for signals we're interested in.
125 (void) sigemptyset(&sa.sa_mask);
127 sa.sa_handler = SIG_DFL;
129 if ((sigaction (SIGINT, (struct sigaction *) 0, &osa) != 0) ||
130 (osa.sa_handler != SIG_IGN))
132 (void) sigaction (SIGINT, &sa, (struct sigaction *) 0);
135 if ((sigaction (SIGHUP, (struct sigaction *) 0, &osa) != 0) ||
136 (osa.sa_handler != SIG_IGN))
138 (void) sigaction (SIGHUP, &sa, (struct sigaction *) 0);
141 (void) sigaction (SIGQUIT, &sa, (struct sigaction *) 0);
142 (void) sigaction (SIGTERM, &sa, (struct sigaction *) 0);
143 (void) sigaction (SIGPIPE, &sa, (struct sigaction *) 0);
144 (void) sigaction (SIGCHLD, &sa, (struct sigaction *) 0);
145 (void) sigaction (SIGILL, &sa, (struct sigaction *) 0);
146 (void) sigaction (SIGFPE, &sa, (struct sigaction *) 0);
147 (void) sigaction (SIGBUS, &sa, (struct sigaction *) 0);
148 (void) sigaction (SIGSEGV, &sa, (struct sigaction *) 0);
150 (void) sigaction (SIGSYS, &sa, (struct sigaction *) 0);
156 /*************************************<->*************************************
158 * SetupWmSignalHandlers ()
163 * This function sets up the signal handlers for the window manager.
165 *************************************<->***********************************/
167 void SetupWmSignalHandlers (int dummy)
169 void (*signalHandler) ();
173 struct sigaction osa;
176 * Catch software signals that we ask the user about
179 (void) sigemptyset(&sa.sa_mask);
181 sa.sa_handler = QuitWmSignalHandler;
183 if ((sigaction (SIGINT, (struct sigaction *) 0, &osa) != 0) ||
184 (osa.sa_handler != SIG_IGN))
186 (void) sigaction (SIGINT, &sa, (struct sigaction *) 0);
189 if ((sigaction (SIGHUP, (struct sigaction *) 0, &osa) != 0) ||
190 (osa.sa_handler != SIG_IGN))
192 (void) sigaction (SIGHUP, &sa, (struct sigaction *) 0);
195 (void) sigaction (SIGQUIT, &sa, (struct sigaction *) 0);
196 (void) sigaction (SIGTERM, &sa, (struct sigaction *) 0);
203 sa.sa_flags = SA_NOCLDWAIT; /* Don't create zombies */
207 sa.sa_handler = SIG_IGN;
208 (void) sigaction (SIGCHLD, &sa, (struct sigaction *) 0);
212 * Catch other fatal signals so we can reset the
213 * keyboard focus to pointer root before aborting
215 sa.sa_handler = AbortWmSignalHandler;
217 (void) sigaction (SIGILL, &sa, (struct sigaction *) 0);
218 (void) sigaction (SIGFPE, &sa, (struct sigaction *) 0);
219 (void) sigaction (SIGBUS, &sa, (struct sigaction *) 0);
220 (void) sigaction (SIGSEGV, &sa, (struct sigaction *) 0);
222 (void) sigaction (SIGSYS, &sa, (struct sigaction *) 0);
225 #else /* not WSM - original mwm code*/
227 signalHandler = (void (*)())signal (SIGINT, SIG_IGN);
228 if (signalHandler != (void (*)())SIG_IGN)
230 signal (SIGINT, QuitWmSignalHandler);
233 signalHandler = (void (*)())signal (SIGHUP, SIG_IGN);
234 if (signalHandler != (void (*)())SIG_IGN)
236 signal (SIGHUP, QuitWmSignalHandler);
239 signal (SIGQUIT, QuitWmSignalHandler);
241 signal (SIGTERM, QuitWmSignalHandler);
245 } /* END OF FUNCTION SetupWmSignalHandlers */
248 /*************************************<->*************************************
250 * QuitWmSignalHandler ()
255 * This function is called on receipt of a signal that is to terminate the
258 *************************************<->***********************************/
260 void QuitWmSignalHandler (int dummy)
262 if (wmGD.showFeedback & WM_SHOW_FB_KILL)
264 ConfirmAction (ACTIVE_PSD, QUIT_MWM_ACTION);
272 } /* END OF FUNCTION QuitWmSignalHandler */