📄 xerrorhandler.cpp
字号:
/* * xerrorhandler.cpp * * Copyright (C) 2001 J. "MUFTI" Scheurich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file "COPYING" for details); if * not, write to the Free Software Foundation, Inc., 675 Mass Ave, * Cambridge, MA 02139, USA. * * Additional License - if you need another License 8-) Permission is hereby granted, free of charge, to any person obtaining a copy of this file, to deal in this file without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of this file, and to permit persons to whom this file is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of this file and that both the above copyright notice(s) and this permission notice appear in supporting documentation. THIS FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS FILE. Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. *//* * tries to catch signals and X11 errors and * try to save the content in case of crashes */#include "xerrorhandler.h"#include "stdafx.h"#include "mysnprintf.h"#include "FreeWRLinputDeviceApp.h"/* * Try to save scenegraphs into files */#ifdef PATH_MAX# define MY_MAX_PATH PATH_MAX#else# ifdef _POSIX_PATH_MAX# define MY_MAX_PATH _POSIX_PATH_MAX# else# define MY_MAX_PATH 255# endif#endif#ifdef WIN32#include "stdafx.h"#include "Windows.h"# define sleep(x)# define myMessageBox(x) MessageBox(NULL,x,"White_dune",MB_ICONINFORMATION);#else# define mywriteerr(x) write(2,x,mystrlen(x));#endifchar* home;void FreeWRLinputDeviceApp::emergency_rescue(void) { if (TheApp->ReturnTracker()) { mywritestr(2,"tracker stopped successfull\n"); } } #ifndef HAVE_WANT_CORE/* * Handler for dangerous Unix Signals: try to save files */ volatile int fatal_error_in_progress = 0; # ifdef HAVE_SIGNAL_INT void signal_fatal_handler(int sign) { signal (sign, SIG_IGN); if (!fatal_error_in_progress) { fatal_error_in_progress = 1; TheApp->emergency_rescue(); signal (sign, SIG_DFL); mywritef(2,"killed by signal %d\n",sign); raise (sign); } }# else void signal_fatal_handler() { for (int i=1;i<=64;i++) signal (i, SIG_IGN); if (!fatal_error_in_progress) { fatal_error_in_progress = 1; TheApp->emergency_rescue(); signal (SIGTERM, SIG_DFL); raise (SIGTERM); } }# endif#endif/* * Initalize Unix Signal Handlers */ # ifndef TRUE# define TRUE 1# define FALSE 0# endif void init_handlers(void) { int i; int dangerous_signals[65]; /* initialise path to $HOME for usage in handler */ home=getenv("HOME");#ifdef HAVE_WANT_CORE return;#else for (i=1;i<=32;i++) dangerous_signals[i]=TRUE; /* list of not dangerous signals */ dangerous_signals[SIGCHLD]=FALSE; dangerous_signals[SIGWINCH]=FALSE; dangerous_signals[SIGURG]=FALSE; dangerous_signals[SIGSTOP]=FALSE; dangerous_signals[SIGTSTP]=FALSE; dangerous_signals[SIGCONT]=FALSE; dangerous_signals[SIGTTIN]=FALSE; dangerous_signals[SIGTTOU]=FALSE;# ifdef SIGCKPT dangerous_signals[SIGCKPT]=FALSE;# endif# ifdef SIGRESTART dangerous_signals[SIGRESTART]=FALSE;# endif /* dangerous_signals[SIGPWR]=FALSE; */ /* handle "dangerous Signals */ for (i=1;i<=32;i++) if (dangerous_signals[i]==TRUE) signal(i,&signal_fatal_handler);// /* ignore CTRL-C interrupts */// signal(SIGINT,SIG_IGN); signal(SIGINT, &signal_fatal_handler); /* handle known interrupts > 32 */# ifdef SIGRTMIN signal(SIGRTMIN,&signal_fatal_handler);# endif# ifdef SIGRTMAX# ifdef __linux__ # ifdef HAVE_GNUC_ECGS_2_8 signal(SIGRTMAX,&signal_fatal_handler);# endif# else signal(SIGRTMAX,&signal_fatal_handler);# endif# endif#endif }void coredump(void) { int *nix=NULL; nix[0]=1; }#ifdef HAVE_FPU_ENABLE_INTERRUPTS# ifdef HAVE_FPU_SETCW# include <fpu_control.h># endif# ifdef HAVE_HANDLE_SIGFPES# include <sigfpe.h># endifvoid fpu_enable_interrupts(void) {# ifdef HAVE_FPU_SETCW unsigned int mask = _FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM ; mask=~mask & _FPU_DEFAULT; _FPU_SETCW(mask); # endif# ifdef HAVE_HANDLE_SIGFPES sigfpe_[_UNDERFL].abort =1; sigfpe_[_OVERFL].abort =1; sigfpe_[_INVALID].abort =1; sigfpe_[_INT_OVERFL].abort=1; sigfpe_[_DIVZERO].abort =1; unsigned int mask = _EN_UNDERFL | _EN_OVERFL | _EN_DIVZERO | _EN_INVALID | _EN_INT_OVERFL; handle_sigfpes(_ON,mask,0,0,0);# endif }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -