Files
itgmania212121/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp
T

97 lines
2.3 KiB
C++
Raw Normal View History

2003-07-24 08:19:20 +00:00
#include "global.h"
#include "RageLog.h"
2004-02-06 04:46:47 +00:00
#include "RageThreads.h"
2003-07-24 08:19:20 +00:00
#include "ArchHooks_Unix.h"
#include "StepMania.h"
2003-07-24 08:19:20 +00:00
#include "archutils/Unix/SignalHandler.h"
2003-11-28 21:34:05 +00:00
#include "archutils/Unix/GetSysInfo.h"
2003-07-24 08:19:20 +00:00
#if defined(CRASH_HANDLER)
2003-07-24 08:19:20 +00:00
#include "archutils/Unix/CrashHandler.h"
#endif
#include "SDL_utils.h"
static bool IsFatalSignal( int signal )
{
switch( signal )
{
case SIGINT:
case SIGTERM:
case SIGHUP:
return false;
2004-03-12 02:58:54 +00:00
default:
return true;
}
}
static void DoCleanShutdown( int signal, siginfo_t *si, const ucontext_t *uc )
{
if( IsFatalSignal(signal) )
return;
/* ^C. */
ExitGame();
}
static void DoCrashSignalHandler( int signal, siginfo_t *si, const ucontext_t *uc )
{
/* Don't dump a debug file if the user just hit ^C. */
if( !IsFatalSignal(signal) )
return;
CrashSignalHandler( signal, si, uc );
}
static void EmergencyShutdown( int signal, siginfo_t *si, const ucontext_t *uc )
{
if( !IsFatalSignal(signal) )
return;
2004-02-06 04:46:47 +00:00
/* If we don't actually use SDL for video, this should be a no-op. Only
* do this if the main thread crashes; trying to shut down from
* another thread causes crashes (eg. GL may be using TLS). */
if( !strcmp(RageThread::GetCurThreadName(), "Main thread") && SDL_WasInit(SDL_INIT_VIDEO) )
SDL_QuitSubSystem(SDL_INIT_VIDEO);
kill( 0, SIGKILL );
}
2003-07-24 08:19:20 +00:00
ArchHooks_Unix::ArchHooks_Unix()
{
/* First, handle non-fatal termination signals. */
SignalHandler::OnClose( DoCleanShutdown );
#if defined(CRASH_HANDLER)
CrashHandlerHandleArgs( g_argc, g_argv );
2003-11-11 23:36:31 +00:00
InitializeCrashHandler();
2004-03-12 02:58:54 +00:00
SignalHandler::OnClose( DoCrashSignalHandler );
2003-07-24 08:19:20 +00:00
#endif
/* Set up EmergencyShutdown, to try to shut down the window if we crash.
* This might blow up, so be sure to do it after the crash handler. */
SignalHandler::OnClose( EmergencyShutdown );
2003-07-24 08:19:20 +00:00
}
void ArchHooks_Unix::DumpDebugInfo()
{
2003-11-28 21:34:05 +00:00
CString sys;
int vers;
GetKernel( sys, vers );
2004-01-02 07:01:27 +00:00
LOG->Info( "OS: %s ver %06i", sys.c_str(), vers );
2003-11-28 21:34:05 +00:00
#if defined(CRASH_HANDLER)
LOG->Info( "Crash backtrace component: %s", BACKTRACE_METHOD_TEXT );
LOG->Info( "Crash lookup component: %s", BACKTRACE_LOOKUP_METHOD_TEXT );
2003-12-22 02:16:33 +00:00
#if defined(BACKTRACE_DEMANGLE_METHOD_TEXT)
2003-12-22 02:16:04 +00:00
LOG->Info( "Crash demangle component: %s", BACKTRACE_DEMANGLE_METHOD_TEXT );
#endif
2003-12-22 02:16:33 +00:00
#endif
}
2003-07-24 08:19:20 +00:00
/*
* Copyright (c) 2003 by the person(s) listed below. All rights reserved.
*
* Glenn Maynard
*/