// Initializes System core, installing allocator. void System::Init() { #if defined(_MSC_VER) // Make it so that failure of the C malloc family of functions results in the same behavior as C++ operator new failure. // This allows us to throw exceptions for malloc usage the same as for operator new bad_alloc. _set_new_mode(1); // Tells the standard library to direct new (and malloc) failures to us. Normally we wouldn't need to do this, as the // C++ Standard Library already throws std::bad_alloc on operator new failure. The problem is that the Standard Library doesn't // throw std::bad_alloc upon malloc failure, and we can only intercept malloc failure via this means. _set_new_handler specifies // a global handler for the current running Standard Library. If the Standard Library is being dynamically linked instead // of statically linked, then this is a problem because a call to _set_new_handler would override anything the application // has already set. _set_new_handler(OVRNewFailureHandler); #else // This allows us to throw OVR::bad_alloc instead of std::bad_alloc, which provides less information. // Question: Does this set the handler for all threads or just the current thread? The C++ Standard doesn't // explicitly state this, though it may be implied from other parts of the Standard. std::set_new_handler(OVRNewFailureHandler); #endif if (++System_Init_Count == 1) { Timer::initializeTimerSystem(); } else { OVR_DEBUG_LOG(("[System] Init recursively called; depth = %d", System_Init_Count)); } }
void NewHandler::init() { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); NewHandler::runtime = (jclass)env->NewGlobalRef(env->FindClass("java/lang/Runtime")); DASSERT(NewHandler::runtime != NULL); NewHandler::getRuntimeID = env->GetStaticMethodID(NewHandler::runtime, "getRuntime", "()Ljava/lang/Runtime;"); NewHandler::gcID = env->GetMethodID(NewHandler::runtime, "gc", "()V"); NewHandler::totalMemoryID = env->GetMethodID(NewHandler::runtime, "totalMemory", "()J"); DASSERT(NewHandler::getRuntimeID != NULL); DASSERT(NewHandler::gcID != NULL); DASSERT(NewHandler::totalMemoryID != NULL); #ifdef OUTOFMEM_TEST alloc_lock = new CriticalSection(); logfile = fopen("java.awt.outofmem.txt", "w"); DASSERT(logfile); thread_seeded = TlsAlloc(); DASSERT(thread_seeded != TLS_OUT_OF_INDEXES); #endif // use new handler for operator new and malloc _set_new_mode(1); // set the function which will be called when operator new or // malloc runs out of memory _set_new_handler((_PNH)NewHandler::handler); }
int CGLViewCtrlApp::ExitInstance() { TRACE("CGLViewCtrlApp::ExitInstance()\n"); #ifdef _DEBUG GView::termClass(); GvDB::term(); #endif // TODO: Add your own module termination code here. EAI_TRACE("CGLViewCtrlApp::ExitInstance()\n"); EAI_FLUSH(); if (GReporter::defaultReporter) { delete GReporter::defaultReporter; GReporter::SetDefault(NULL); } // MFC's class factories registration is automatically revoked by MFC itself _Module.RevokeClassObjects(); // Revoke class factories for ATL _Module.Term(); // cleanup ATL GLobal Module _set_new_handler(cc3d_old_new_handler); _set_new_mode(cc3d_old_new_mode); // for malloc too return COleControlModule::ExitInstance(); }
void xrDebug::_initialize (const bool &dedicated) { handler = 0; _set_new_mode (1); // gen exception if can't allocate memory _set_new_handler (_out_of_memory ); // exception-handler for 'out of memory' condition std::set_terminate (_terminate); std::set_unexpected (_terminate); ::SetUnhandledExceptionFilter ( UnhandledFilter ); // exception handler to all "unhandled" exceptions }
//------------------------------------------------------------------------------------------------------ // Function: TFStats_setNewHandler // Purpose: sets the new handler to the TFStats new handler //------------------------------------------------------------------------------------------------------ void TFStats_setNewHandler() { #ifdef WIN32 _set_new_handler(TFStats_win32_new_handler); _set_new_mode(1); #else std::set_new_handler(TFStats_linux_new_handler); //std::set_new_mode(1); #endif }
int __cdecl __wgetmainargs(int * _Argc, wchar_t *** _Argv, wchar_t ***_Env, int _DoWildCard, _startupinfo *_StartInfo) { _initialize_wide_environment(); _configure_wide_argv(_DoWildCard ? 2 : 1); *_Argc = *__p___argc(); *_Argv = *__p___wargv(); *_Env = *__p__wenviron(); if (_StartInfo) _set_new_mode(_StartInfo->newmode); return 0; }
extern "C" void cbStartup() { cbLock = CreateMutex( NULL, FALSE, NULL ); cbReportData = NULL; swprintf_s( cbShareName, 256, L"CrashBack_%x", GetCurrentProcessId() ); GetModuleFileName( NULL, cbReportExePath, MAX_PATH ); wcscpy_s( cbReportExeDir, MAX_PATH, cbReportExePath ); wchar_t *p = wcsrchr( cbReportExeDir, '\\' ); if ( p ) *p = 0; wcscpy_s( cbReportExePath, MAX_PATH, cbReportExeDir ); wcscat_s( cbReportExePath, MAX_PATH, L"\\" ); wcscat_s( cbReportExePath, MAX_PATH, L"crashreport.exe" ); // Check that crashreport.exe exists in the app's directory. if ( GetFileAttributes( cbReportExePath ) == INVALID_FILE_ATTRIBUTES ) return; swprintf_s( cbReportCmdLine, 1024, L"\"%s\" 0x%x", cbReportExePath, GetCurrentProcessId() ); cbGetProgramName(); cbGetCmdLine(); // Set up shared memory to communicate with the report handler EXE. HANDLE hShared = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file NULL, // default security PAGE_READWRITE, // read/write access 0, // max. object size sizeof(CbReport), // buffer size cbShareName ); // name of mapping object if ( !hShared ) return; cbReportData = (CbReport *)MapViewOfFile( hShared, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(CbReport) ); if ( !cbReportData ) { CloseHandle( hShared ); return; } // Register the handlers. SetUnhandledExceptionFilter( &cbExceptionHandler ); _set_error_mode( _OUT_TO_STDERR ); _set_purecall_handler( cbPureCallHandler ); _set_new_mode( 1 ); // malloc calls the new handler on failure _set_new_handler( cbNewHandler ); _set_invalid_parameter_handler( cbInvalidParameterHandler ); _set_abort_behavior( _CALL_REPORTFAULT, _CALL_REPORTFAULT ); }
void NewHandler::init() { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); #ifdef OUTOFMEM_TEST alloc_lock = new CriticalSection(); logfile = fopen("java.awt.outofmem.txt", "w"); DASSERT(logfile); thread_seeded = TlsAlloc(); DASSERT(thread_seeded != TLS_OUT_OF_INDEXES); #endif // use new handler for operator new and malloc _set_new_mode(1); // set the function which will be called when operator new or // malloc runs out of memory _set_new_handler((_PNH)NewHandler::handler); }
bool CrashHandlerWindows::registerCrashHandlers() { arx_assert(m_pPreviousCrashHandlers == 0); m_pPreviousCrashHandlers = new PlatformCrashHandlers; // Unhandled exception handler. m_pPreviousCrashHandlers->m_SEHHandler = SetUnhandledExceptionFilter(SEHHandler); // Prevent dialog box. _set_error_mode(_OUT_TO_STDERR); // Catch pure virtual function calls. // Because there is one _purecall_handler for the whole process, // calling this function immediately impacts all threads. The last // caller on any thread sets the handler. // http://msdn.microsoft.com/en-us/library/t296ys27.aspx m_pPreviousCrashHandlers->m_pureCallHandler = _set_purecall_handler(PureCallHandler); // Catch new operator memory allocation exceptions. _set_new_mode(1); // Force malloc() to call new handler too m_pPreviousCrashHandlers->m_newHandler = _set_new_handler(NewHandler); // Catch invalid parameter exceptions. m_pPreviousCrashHandlers->m_invalidParameterHandler = _set_invalid_parameter_handler(InvalidParameterHandler); // Catch an abnormal program termination. _set_abort_behavior(_CALL_REPORTFAULT, _CALL_REPORTFAULT); m_pPreviousCrashHandlers->m_SIGABRTHandler = signal(SIGABRT, SignalHandler); // Catch illegal instruction handler. m_pPreviousCrashHandlers->m_SIGINTHandler = signal(SIGINT, SignalHandler); // Catch a termination request. m_pPreviousCrashHandlers->m_SIGTERMHandler = signal(SIGTERM, SignalHandler); // We must also register the main thread crash handlers. return registerThreadCrashHandlers(); }
void initialize_FramepaC(int max_symbols) { if (!Initialized) { FrShutdown = shutdown_FramepaC ; FrSymbolTable::current()->expandTo(max_symbols) ; void FramepaC_init_inheritance_setting_func() ; FramepaC_init_inheritance_setting_func() ; initialize_FrReadTable() ; #if defined(__SUNOS__) && !defined(__SOLARIS__) // SunOS 4.x has on_exit() instead of the standard atexit(); Solaris // has atexit() but no on_exit().... on_exit(shutdown_FramepaC_sun,(caddr_t) 0) ; #elif defined(_MSC_VER) atexit(shutdown_FramepaC_VC) ; _set_new_mode(1) ; // do GC if malloc() fails #else atexit(shutdown_FramepaC) ; #endif /* __SUNOS__ && !__SOLARIS__ */ Initialized = true ; } return ; }
BOOL CGLViewCtrlApp::InitInstance() { TRACE("CGLViewCtrlApp::InitInstance() \n"); cc3d_old_new_handler=_set_new_handler(cc3d_new_handler); cc3d_old_new_mode=_set_new_mode(1); // for malloc too #ifdef _KATMAI if (!KatmaiInit()) { // AfxMessageBox("This version requires an Intel Katmai processor \n Program will be terminated "); //MessageBox(NULL,"This version requires an Intel Katmai processor \n Program will be terminated " ,_PROGRAM,MB_OK); //return FALSE; } else { TRACE("CGLViewCtrlApp::Running on Intel Katmai processor \n"); } #endif BOOL bInit = COleControlModule::InitInstance(); // Initialize the ATL Module _Module.Init(ObjectMap,m_hInstance); #if 0 // only for EXE's #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif VERIFY(SUCCEEDED(_Module.RegisterServer(TRUE)));// ATL Classes //VERIFY(SUCCEEDED(_Module.RegisterTypeLib("glviewvrml.tlb")));// type lib if (bInit) { // TODO: Add your own module initialization code here. // set the default error reporting object GReporter::SetCurrent(new GReporter()); GReporter::SetDefault(GReporter::current); #ifdef _EAI_TRACE // for tracing EAI calls if (GTrace::current == NULL) { FILE *f = fopen("\\temp\\glviewlog.txt","w"); GTrace::SetCurrent(new GTrace(f)); } #endif EAI_TRACE("CGLViewCtrlApp::InitInstance()\n"); EAI_FLUSH(); // make sure Gv VRML database is init GvDB::init(); // set the cache directory CString tmp; CString installDir; if (1) { // use local install directory GetModuleFileName(AfxGetInstanceHandle( ), tmp.GetBuffer(_MAX_PATH),_MAX_PATH); tmp.ReleaseBuffer(); int iBackslash = tmp.ReverseFind('\\'); if (iBackslash != -1) tmp = tmp.Left(iBackslash+1); installDir = tmp; } else { GetTempPath(_MAX_PATH,tmp.GetBuffer(_MAX_PATH)); tmp.ReleaseBuffer(); } if (tmp.GetLength()>0) { int l = tmp.GetLength(); if (tmp[l-1] != '\\') tmp += '\\'; } tmp += "cache"; GFile::cacheDirectory = tmp; TRACE("Cache directory is : %s \n",(const char *)tmp); // set the new ini-file name (stored in the ccpro directory, name is cc3d.ini) tmp = installDir + "cc3d.ini"; if (m_pszProfileName) free( (void*)m_pszProfileName ); m_pszProfileName = _tcsdup( tmp ); TRACE("Ini file is : %s \n",(const char *)tmp); if (m_pszAppName) free( (void*)m_pszAppName ); m_pszAppName = _tcsdup(_PROGRAM); } return bInit; }
void ase_install_malloc_hook() { _set_new_mode(1); _set_new_handler(mhook_handle_oom); }
void InstallAllocationFunctions() { _set_new_mode( 1 ); // so if malloc() fails, we exit. _set_new_handler( CmdLib_NewHandler ); }
/** * @brief Initializes the application. */ bool App::OnInit() { // initialize wxWidgets SetAppName(wxT("UltraDefrag")); wxInitAllImageHandlers(); if(!wxApp::OnInit()) return false; // initialize udefrag library if(::udefrag_init_library() < 0){ wxLogError(wxT("Initialization failed!")); return false; } // set out of memory handler #if !defined(__GNUC__) winx_set_killer(out_of_memory_handler); _set_new_handler(out_of_memory_handler); _set_new_mode(1); #endif // initialize debug log wxFileName logpath(wxT(".\\logs\\ultradefrag.log")); logpath.Normalize(); wxSetEnv(wxT("UD_LOG_FILE_PATH"),logpath.GetFullPath()); ::udefrag_set_log_file_path(); // initialize logging m_log = new Log(); // use global config object for internal settings wxFileConfig *cfg = new wxFileConfig(wxT(""),wxT(""), wxT("gui.ini"),wxT(""),wxCONFIG_USE_RELATIVE_PATH); wxConfigBase::Set(cfg); // enable i18n support InitLocale(); // save report translation on setup wxString cmdLine(GetCommandLine()); if(cmdLine.Find(wxT("--setup")) != wxNOT_FOUND){ SaveReportTranslation(); ::winx_flush_dbg_log(0); delete m_log; return false; } // start web statistics m_statThread = new StatThread(); // check for administrative rights if(!Utils::CheckAdminRights()){ wxMessageDialog dlg(NULL, wxT("Administrative rights are needed to run the program!"), wxT("UltraDefrag"),wxOK | wxICON_ERROR ); dlg.ShowModal(); Cleanup(); return false; } // create synchronization event g_synchEvent = ::CreateEvent(NULL,TRUE,FALSE,NULL); if(!g_synchEvent){ letrace("cannot create synchronization event"); wxMessageDialog dlg(NULL, wxT("Cannot create synchronization event!"), wxT("UltraDefrag"),wxOK | wxICON_ERROR ); dlg.ShowModal(); Cleanup(); return false; } // keep things DPI-aware HDC hdc = ::GetDC(NULL); if(hdc){ g_scaleFactor = (double)::GetDeviceCaps(hdc,LOGPIXELSX) / 96.0f; ::ReleaseDC(NULL,hdc); } g_iconSize = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X); if(g_iconSize < 20) g_iconSize = 16; else if(g_iconSize < 24) g_iconSize = 20; else if(g_iconSize < 32) g_iconSize = 24; else g_iconSize = 32; // support taskbar icon overlay setup on shell restart g_TaskbarIconMsg = ::RegisterWindowMessage(wxT("TaskbarButtonCreated")); if(!g_TaskbarIconMsg) letrace("cannot register TaskbarButtonCreated message"); // create main window g_mainFrame = new MainFrame(); g_mainFrame->Show(true); SetTopWindow(g_mainFrame); return true; }
int CCrashHandler::SetProcessExceptionHandlers(DWORD dwFlags) { crSetErrorMsg(_T("Unspecified error.")); // If 0 is specified as dwFlags, assume all handlers should be // installed if((dwFlags&0x1FF)==0) dwFlags |= 0x1FFF; if(dwFlags&CR_INST_STRUCTURED_EXCEPTION_HANDLER) { // Install top-level SEH handler m_oldSehHandler = SetUnhandledExceptionFilter(SehHandler); } _set_error_mode(_OUT_TO_STDERR); #if _MSC_VER>=1300 if(dwFlags&CR_INST_PURE_CALL_HANDLER) { // Catch pure virtual function calls. // Because there is one _purecall_handler for the whole process, // calling this function immediately impacts all threads. The last // caller on any thread sets the handler. // http://msdn.microsoft.com/en-us/library/t296ys27.aspx m_prevPurec = _set_purecall_handler(PureCallHandler); } if(dwFlags&CR_INST_NEW_OPERATOR_ERROR_HANDLER) { // Catch new operator memory allocation exceptions _set_new_mode(1); // Force malloc() to call new handler too m_prevNewHandler = _set_new_handler(NewHandler); } #endif #if _MSC_VER>=1400 if(dwFlags&CR_INST_INVALID_PARAMETER_HANDLER) { // Catch invalid parameter exceptions. m_prevInvpar = _set_invalid_parameter_handler(InvalidParameterHandler); } #endif #if _MSC_VER>=1300 && _MSC_VER<1400 if(dwFlags&CR_INST_SECURITY_ERROR_HANDLER) { // Catch buffer overrun exceptions // The _set_security_error_handler is deprecated in VC8 C++ run time library m_prevSec = _set_security_error_handler(SecurityHandler); } #endif // Set up C++ signal handlers if(dwFlags&CR_INST_SIGABRT_HANDLER) { #if _MSC_VER>=1400 _set_abort_behavior(_CALL_REPORTFAULT, _CALL_REPORTFAULT); #endif // Catch an abnormal program termination m_prevSigABRT = signal(SIGABRT, SigabrtHandler); } if(dwFlags&CR_INST_SIGILL_HANDLER) { // Catch illegal instruction handler m_prevSigINT = signal(SIGINT, SigintHandler); } if(dwFlags&CR_INST_TERMINATE_HANDLER) { // Catch a termination request m_prevSigTERM = signal(SIGTERM, SigtermHandler); } crSetErrorMsg(_T("Success.")); return 0; }
int main(int argc,char*argv[]) { #ifdef _DEBUG Test_DoAllTests(); #endif int res; main_init(); res = main_preprocess_cmdline(argc, argv); if (res != RETURN_CONTINUE) { return res; } initialize_debug_system(); Out::FPrint("Adventure Game Studio v%s Interpreter\n" "Copyright (c) 1999-2011 Chris Jones and " ACI_COPYRIGHT_YEARS " others\n" #ifdef BUILD_STR "ACI version %s (Build: %s)\n", EngineVersion.ShortString.GetCStr(), EngineVersion.LongString.GetCStr(), EngineVersion.BuildInfo.GetCStr()); #else "ACI version %s\n", EngineVersion.ShortString.GetCStr(), EngineVersion.LongString.GetCStr()); #endif if ((argc>1) && (stricmp(argv[1],"--help") == 0 || argv[1][1]=='?')) { main_print_help(); return 0; } Out::FPrint("*** ENGINE STARTUP ***"); #if defined(WINDOWS_VERSION) _set_new_handler(malloc_fail_handler); _set_new_mode(1); printfworkingspace=(char*)malloc(7000); #endif debug_flags=0; res = main_process_cmdline(argc, argv); if (res != RETURN_CONTINUE) { return res; } main_init_crt_report(); main_set_gamedir(argc, argv); // Update shell associations and exit if (debug_flags & DBG_REGONLY) exit(0); #ifndef USE_CUSTOM_EXCEPTION_HANDLER usetup.disable_exception_handling = true; #endif if (usetup.disable_exception_handling) { int result = initialize_engine(argc, argv); platform->PostAllegroExit(); return result; } else { return initialize_engine_with_exception_handling(argc, argv); } }
// Called from MyApp() immediately upon entry to MyApp::OnInit() void OCPNPlatform::Initialize_1( void ) { #ifdef OCPN_USE_CRASHRPT #ifndef _DEBUG // Install Windows crash reporting CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("OpenCPN"); wxString version_crash = str_version_major + _T(".") + str_version_minor + _T(".") + str_version_patch; info.pszAppVersion = version_crash.c_str(); int type = MiniDumpWithDataSegs; // Include the data sections from all loaded modules. // This results in the inclusion of global variables type |= MiniDumpNormal;// | MiniDumpWithPrivateReadWriteMemory | MiniDumpWithIndirectlyReferencedMemory; info.uMiniDumpType = (MINIDUMP_TYPE)type; // Install all available exception handlers.... info.dwFlags = CR_INST_ALL_POSSIBLE_HANDLERS; // Except memory allocation failures info.dwFlags &= ~CR_INST_NEW_OPERATOR_ERROR_HANDLER; // Allow user to attach files info.dwFlags |= CR_INST_ALLOW_ATTACH_MORE_FILES; // Allow user to add more info info.dwFlags |= CR_INST_SHOW_ADDITIONAL_INFO_FIELDS; // URL for sending error reports over HTTP. if(g_bEmailCrashReport){ info.pszEmailTo = _T("*****@*****.**"); info.pszSmtpProxy = _T("mail.bigdumboat.com:587"); info.pszUrl = _T("http://bigdumboat.com/crashrpt/ocpn_crashrpt.php"); info.uPriorities[CR_HTTP] = 1; // First try send report over HTTP } else{ info.dwFlags |= CR_INST_DONT_SEND_REPORT; info.uPriorities[CR_HTTP] = CR_NEGATIVE_PRIORITY; // don't send at all } info.uPriorities[CR_SMTP] = CR_NEGATIVE_PRIORITY; // Second try send report over SMTP info.uPriorities[CR_SMAPI] = CR_NEGATIVE_PRIORITY; //1; // Third try send report over Simple MAPI wxStandardPaths& crash_std_path = g_Platform->GetStdPaths(); wxString crash_rpt_save_locn = crash_std_path.GetConfigDir(); if( g_bportable ) { wxFileName exec_path_crash( crash_std_path.GetExecutablePath() ); crash_rpt_save_locn = exec_path_crash.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR ); } wxString locn = crash_rpt_save_locn + _T("\\CrashReports"); if(!wxDirExists( locn ) ) wxMkdir( locn ); if(wxDirExists( locn ) ){ wxCharBuffer buf = locn.ToUTF8(); wchar_t wlocn[256]; if(buf && (locn.Length() < sizeof(wlocn)) ){ MultiByteToWideChar( 0, 0, buf.data(), -1, wlocn, sizeof(wlocn)-1); info.pszErrorReportSaveDir = (LPCWSTR)wlocn; } } // Provide privacy policy URL wxFileName exec_path_crash( crash_std_path.GetExecutablePath() ); wxString policy_file = exec_path_crash.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR ); policy_file += _T("PrivacyPolicy.txt"); policy_file.Prepend(_T("file:")); info.pszPrivacyPolicyURL = policy_file.c_str();; int nResult = crInstall(&info); if(nResult!=0) { TCHAR buff[256]; crGetLastErrorMsg(buff, 256); MessageBox(NULL, buff, _T("crInstall error, Crash Reporting disabled."), MB_OK); } // Establish the crash callback function crSetCrashCallback( CrashCallback, NULL ); // Take screenshot of the app window at the moment of crash crAddScreenshot2(CR_AS_PROCESS_WINDOWS|CR_AS_USE_JPEG_FORMAT, 95); // Mark some files to add to the crash report wxString home_data_crash = crash_std_path.GetConfigDir(); if( g_bportable ) { wxFileName f( crash_std_path.GetExecutablePath() ); home_data_crash = f.GetPath(); } appendOSDirSlash( &home_data_crash ); wxString config_crash = _T("opencpn.ini"); config_crash.Prepend( home_data_crash ); crAddFile2( config_crash.c_str(), NULL, NULL, CR_AF_MISSING_FILE_OK | CR_AF_ALLOW_DELETE ); wxString log_crash = _T("opencpn.log"); log_crash.Prepend( home_data_crash ); crAddFile2( log_crash.c_str(), NULL, NULL, CR_AF_MISSING_FILE_OK | CR_AF_ALLOW_DELETE ); #endif #endif #ifdef LINUX_CRASHRPT #if wxUSE_ON_FATAL_EXCEPTION // fatal exceptions handling wxHandleFatalExceptions (true); #endif #endif #ifdef __WXMSW__ // Invoke my own handler for failures of malloc/new _set_new_handler( MyNewHandler ); // configure malloc to call the New failure handler on failure _set_new_mode(1); #endif // On MSW, force the entire process to run on one CPU core only // This resolves some difficulty with wxThread syncronization #if 0 #ifdef __WXMSW__ //Gets the current process handle HANDLE hProc = GetCurrentProcess(); DWORD procMask; DWORD sysMask; HANDLE hDup; DuplicateHandle( hProc, hProc, hProc, &hDup, 0, FALSE, DUPLICATE_SAME_ACCESS ); //Gets the current process affinity mask GetProcessAffinityMask( hDup, &procMask, &sysMask ); // Take a simple approach, and assume up to 4 processors DWORD newMask; if( ( procMask & 1 ) == 1 ) newMask = 1; else if( ( procMask & 2 ) == 2 ) newMask = 2; else if( ( procMask & 4 ) == 4 ) newMask = 4; else if( ( procMask & 8 ) == 8 ) newMask = 8; //Set te affinity mask for the process BOOL res = SetProcessAffinityMask( hDup, (DWORD_PTR) newMask ); if( res == 0 ) { //Error setting affinity mask!! } #endif #endif #ifdef __WXMSW__ // Handle any Floating Point Exceptions which may leak thru from other // processes. The exception filter is in cutil.c // Seems to only happen for W98 wxPlatformInfo Platform; if( Platform.GetOperatingSystemId() == wxOS_WINDOWS_9X ) SetUnhandledExceptionFilter (&MyUnhandledExceptionFilter); #endif #ifdef __WXMSW__ // _CrtSetBreakAlloc(25503); #endif #ifndef __WXMSW__ // Setup Linux SIGNAL handling, for external program control // Build the sigaction structure sa_all.sa_handler = catch_signals;// point to my handler sigemptyset(&sa_all.sa_mask);// make the blocking set // empty, so that all // other signals will be // unblocked during my handler sa_all.sa_flags = 0; sigaction(SIGUSR1, NULL, &sa_all_old);// save existing action for this signal // Register my request for some signals sigaction(SIGUSR1, &sa_all, NULL); sigaction(SIGUSR1, NULL, &sa_all_old);// inspect existing action for this signal sigaction(SIGTERM, &sa_all, NULL); sigaction(SIGTERM, NULL, &sa_all_old); #endif }