int boinc_install_signal_handlers() { #ifdef _WIN32 SetUnhandledExceptionFilter(boinc_catch_signal); #if defined(_MSC_VER) && (_MSC_VER >= 1400) _set_invalid_parameter_handler(boinc_catch_signal_invalid_parameter); #endif #else //_WIN32 // register handlers for fatal internal signals // so that they get reported in stderr.txt // Do NOT catch SIGQUIT because core client uses that to kill app // boinc_set_signal_handler(SIGILL, boinc_catch_signal); boinc_set_signal_handler(SIGABRT, boinc_catch_signal); boinc_set_signal_handler(SIGBUS, boinc_catch_signal); boinc_set_signal_handler(SIGSEGV, boinc_catch_signal); boinc_set_signal_handler(SIGSYS, boinc_catch_signal); boinc_set_signal_handler(SIGPIPE, boinc_catch_signal); #endif //_WIN32 return 0; }
static void init_core_client(int argc, char** argv) { setbuf(stdout, 0); setbuf(stderr, 0); cc_config.defaults(); gstate.parse_cmdline(argc, argv); gstate.now = dtime(); #ifdef _WIN32 if (!cc_config.allow_multiple_clients) { chdir_to_data_dir(); } #endif #ifndef _WIN32 if (g_use_sandbox) // Set file creation mask to be writable by both user and group and // world-executable but neither world-readable nor world-writable // Our umask will be inherited by all our child processes // umask (6); #endif // Initialize the BOINC Diagnostics Framework int flags = #ifdef _DEBUG BOINC_DIAG_MEMORYLEAKCHECKENABLED | #endif BOINC_DIAG_DUMPCALLSTACKENABLED | BOINC_DIAG_HEAPCHECKENABLED | BOINC_DIAG_TRACETOSTDOUT; if (gstate.redirect_io || gstate.executing_as_daemon || gstate.detach_console) { flags |= BOINC_DIAG_REDIRECTSTDERR | BOINC_DIAG_REDIRECTSTDOUT; } diagnostics_init(flags, "stdoutdae", "stderrdae"); #ifdef _WIN32 // Specify which allocation will cause a debugger to break. Use a previous // memory leak detection report which looks like this: // {650} normal block at 0x000000000070A6F0, 24 bytes long. // Data: < N P p > 80 1E 4E 00 00 00 00 00 50 AE 70 00 00 00 00 00 //_CrtSetBreakAlloc(650); //_CrtSetBreakAlloc(651); //_CrtSetBreakAlloc(652); //_CrtSetBreakAlloc(653); //_CrtSetBreakAlloc(654); #endif read_config_file(true); // Win32 - detach from console if requested #ifdef _WIN32 if (gstate.detach_console) { FreeConsole(); } #endif // Unix: install signal handlers #ifndef _WIN32 // Handle quit signals gracefully boinc_set_signal_handler(SIGHUP, (handler_t)signal_handler); boinc_set_signal_handler(SIGINT, (handler_t)signal_handler); boinc_set_signal_handler(SIGQUIT, (handler_t)signal_handler); boinc_set_signal_handler(SIGTERM, (handler_t)signal_handler); #ifdef SIGPWR boinc_set_signal_handler(SIGPWR, (handler_t)signal_handler); #endif #endif }