123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
- /*
- * Motif Release 1.2
- */
- /*
- * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
- /*
- * Included Files:
- */
- #include "WmGlobal.h" /* This should be the first include */
- #include <signal.h>
- #include <unistd.h>
- /*
- * include extern functions
- */
- #include "WmFeedback.h"
- #include "WmFunction.h"
- /*
- * Function Declarations:
- */
- #include "WmSignal.h"
- /*
- * Global Variables:
- */
- /*************************************<->*************************************
- *
- * AbortWmSignalHandler ()
- *
- *
- * Description:
- * -----------
- * This function is called on receipt of a fatal signal. We reset
- * the keyboard focus to pointer root before aborting.
- *
- *************************************<->***********************************/
- static void
- AbortWmSignalHandler (int sig)
- {
- struct sigaction sa;
- /*
- * Set input focus back to pointer root
- */
- XSetInputFocus(DISPLAY, PointerRoot, RevertToPointerRoot, CurrentTime);
- XSync (DISPLAY, False);
- XCloseDisplay (DISPLAY);
- /*
- * Invoke the default handler
- */
- (void) sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
- (void) sigaction (sig, &sa, (struct sigaction *) 0);
- kill (getpid(), sig);
- } /* END OF FUNCTION AbortSignalHandler */
- /*************************************<->*************************************
- *
- * RestoreDefaultSignalHandlers ()
- *
- *
- * Description:
- * -----------
- * This function sets up the signal handlers for the window manager.
- *
- *************************************<->***********************************/
- void
- RestoreDefaultSignalHandlers (void)
- {
- struct sigaction sa;
- struct sigaction osa;
- /*
- * Restore default action for signals we're interested in.
- */
- (void) sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
- if ((sigaction (SIGINT, (struct sigaction *) 0, &osa) != 0) ||
- (osa.sa_handler != SIG_IGN))
- {
- (void) sigaction (SIGINT, &sa, (struct sigaction *) 0);
- }
- if ((sigaction (SIGHUP, (struct sigaction *) 0, &osa) != 0) ||
- (osa.sa_handler != SIG_IGN))
- {
- (void) sigaction (SIGHUP, &sa, (struct sigaction *) 0);
- }
- (void) sigaction (SIGQUIT, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGTERM, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGPIPE, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGCHLD, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGILL, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGFPE, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGBUS, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGSEGV, &sa, (struct sigaction *) 0);
- #ifdef SIGSYS
- (void) sigaction (SIGSYS, &sa, (struct sigaction *) 0);
- #endif
- }
- /*************************************<->*************************************
- *
- * SetupWmSignalHandlers ()
- *
- *
- * Description:
- * -----------
- * This function sets up the signal handlers for the window manager.
- *
- *************************************<->***********************************/
- void SetupWmSignalHandlers (int dummy)
- {
- struct sigaction sa;
- struct sigaction osa;
- /*
- * Catch software signals that we ask the user about
- * before quitting.
- */
- (void) sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = QuitWmSignalHandler;
- if ((sigaction (SIGINT, (struct sigaction *) 0, &osa) != 0) ||
- (osa.sa_handler != SIG_IGN))
- {
- (void) sigaction (SIGINT, &sa, (struct sigaction *) 0);
- }
- if ((sigaction (SIGHUP, (struct sigaction *) 0, &osa) != 0) ||
- (osa.sa_handler != SIG_IGN))
- {
- (void) sigaction (SIGHUP, &sa, (struct sigaction *) 0);
- }
- (void) sigaction (SIGQUIT, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGTERM, &sa, (struct sigaction *) 0);
- /*
- * Ignore child death
- */
- #ifdef SA_NOCLDWAIT
- sa.sa_flags = SA_NOCLDWAIT; /* Don't create zombies */
- #else
- sa.sa_flags = 0;
- #endif
- sa.sa_handler = SIG_IGN;
- (void) sigaction (SIGCHLD, &sa, (struct sigaction *) 0);
- sa.sa_flags = 0;
- /*
- * Catch other fatal signals so we can reset the
- * keyboard focus to pointer root before aborting
- */
- sa.sa_handler = AbortWmSignalHandler;
- (void) sigaction (SIGILL, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGFPE, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGBUS, &sa, (struct sigaction *) 0);
- (void) sigaction (SIGSEGV, &sa, (struct sigaction *) 0);
- #ifdef SIGSYS
- (void) sigaction (SIGSYS, &sa, (struct sigaction *) 0);
- #endif
- } /* END OF FUNCTION SetupWmSignalHandlers */
- /*************************************<->*************************************
- *
- * QuitWmSignalHandler ()
- *
- *
- * Description:
- * -----------
- * This function is called on receipt of a signal that is to terminate the
- * window manager.
- *
- *************************************<->***********************************/
- void QuitWmSignalHandler (int dummy)
- {
- if (wmGD.showFeedback & WM_SHOW_FB_KILL)
- {
- ConfirmAction (ACTIVE_PSD, QUIT_MWM_ACTION);
- XFlush(DISPLAY);
- }
- else
- {
- Do_Quit_Mwm(False);
- }
- } /* END OF FUNCTION QuitWmSignalHandler */
|