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 libraries 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.
31 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
37 #include "WmGlobal.h" /* This should be the first include */
43 * include extern functions
46 #include "WmFeedback.h"
47 #include "WmFunction.h"
51 * Function Declarations:
63 /*************************************<->*************************************
65 * AbortWmSignalHandler ()
70 * This function is called on receipt of a fatal signal. We reset
71 * the keyboard focus to pointer root before aborting.
73 *************************************<->***********************************/
75 AbortWmSignalHandler (int sig)
80 * Set input focus back to pointer root
82 XSetInputFocus(DISPLAY, PointerRoot, RevertToPointerRoot, CurrentTime);
83 XSync (DISPLAY, False);
84 XCloseDisplay (DISPLAY);
87 * Invoke the default handler
89 (void) sigemptyset(&sa.sa_mask);
91 sa.sa_handler = SIG_DFL;
92 (void) sigaction (sig, &sa, (struct sigaction *) 0);
96 } /* END OF FUNCTION AbortSignalHandler */
99 /*************************************<->*************************************
101 * RestoreDefaultSignalHandlers ()
106 * This function sets up the signal handlers for the window manager.
108 *************************************<->***********************************/
111 RestoreDefaultSignalHandlers (void)
114 struct sigaction osa;
117 * Restore default action for signals we're interested in.
120 (void) sigemptyset(&sa.sa_mask);
122 sa.sa_handler = SIG_DFL;
124 if ((sigaction (SIGINT, (struct sigaction *) 0, &osa) != 0) ||
125 (osa.sa_handler != SIG_IGN))
127 (void) sigaction (SIGINT, &sa, (struct sigaction *) 0);
130 if ((sigaction (SIGHUP, (struct sigaction *) 0, &osa) != 0) ||
131 (osa.sa_handler != SIG_IGN))
133 (void) sigaction (SIGHUP, &sa, (struct sigaction *) 0);
136 (void) sigaction (SIGQUIT, &sa, (struct sigaction *) 0);
137 (void) sigaction (SIGTERM, &sa, (struct sigaction *) 0);
138 (void) sigaction (SIGPIPE, &sa, (struct sigaction *) 0);
139 (void) sigaction (SIGCHLD, &sa, (struct sigaction *) 0);
140 (void) sigaction (SIGILL, &sa, (struct sigaction *) 0);
141 (void) sigaction (SIGFPE, &sa, (struct sigaction *) 0);
142 (void) sigaction (SIGBUS, &sa, (struct sigaction *) 0);
143 (void) sigaction (SIGSEGV, &sa, (struct sigaction *) 0);
145 (void) sigaction (SIGSYS, &sa, (struct sigaction *) 0);
150 /*************************************<->*************************************
152 * SetupWmSignalHandlers ()
157 * This function sets up the signal handlers for the window manager.
159 *************************************<->***********************************/
161 void SetupWmSignalHandlers (int dummy)
164 struct sigaction osa;
167 * Catch software signals that we ask the user about
170 (void) sigemptyset(&sa.sa_mask);
172 sa.sa_handler = QuitWmSignalHandler;
174 if ((sigaction (SIGINT, (struct sigaction *) 0, &osa) != 0) ||
175 (osa.sa_handler != SIG_IGN))
177 (void) sigaction (SIGINT, &sa, (struct sigaction *) 0);
180 if ((sigaction (SIGHUP, (struct sigaction *) 0, &osa) != 0) ||
181 (osa.sa_handler != SIG_IGN))
183 (void) sigaction (SIGHUP, &sa, (struct sigaction *) 0);
186 (void) sigaction (SIGQUIT, &sa, (struct sigaction *) 0);
187 (void) sigaction (SIGTERM, &sa, (struct sigaction *) 0);
194 sa.sa_flags = SA_NOCLDWAIT; /* Don't create zombies */
198 sa.sa_handler = SIG_IGN;
199 (void) sigaction (SIGCHLD, &sa, (struct sigaction *) 0);
203 * Catch other fatal signals so we can reset the
204 * keyboard focus to pointer root before aborting
206 sa.sa_handler = AbortWmSignalHandler;
208 (void) sigaction (SIGILL, &sa, (struct sigaction *) 0);
209 (void) sigaction (SIGFPE, &sa, (struct sigaction *) 0);
210 (void) sigaction (SIGBUS, &sa, (struct sigaction *) 0);
211 (void) sigaction (SIGSEGV, &sa, (struct sigaction *) 0);
213 (void) sigaction (SIGSYS, &sa, (struct sigaction *) 0);
216 } /* END OF FUNCTION SetupWmSignalHandlers */
219 /*************************************<->*************************************
221 * QuitWmSignalHandler ()
226 * This function is called on receipt of a signal that is to terminate the
229 *************************************<->***********************************/
231 void QuitWmSignalHandler (int dummy)
233 if (wmGD.showFeedback & WM_SHOW_FB_KILL)
235 ConfirmAction (ACTIVE_PSD, QUIT_MWM_ACTION);
243 } /* END OF FUNCTION QuitWmSignalHandler */