Ejemplo n.º 1
0
/**
 * @brief Single exit point (regular exit or in case of error)
 */
static __attribute__ ((noreturn)) void Sys_Exit(int exitCode)
{
	CON_Shutdown();

#ifndef DEDICATED
	SDL_Quit();
#endif

#ifdef __MORPHOS__
	CloseLibrary(DynLoadBase);
#endif

	if (exitCode < 2)
	{
		// Normal exit
		const char *pidfile = Cvar_VariableString("com_pidfile");

		// com_pidfile does not yet exist on early exit
		if (pidfile[0] != '\0')
		{
			if (FS_FileExists(pidfile))
			{
				// FIXME: delete even when outside of homepath
				remove(va("%s%c%s%c%s", Cvar_VariableString("fs_homepath"),
				          PATH_SEP, Cvar_VariableString("fs_game"),
				          PATH_SEP, com_pidfile->string));
			}
		}
	}

	exit(exitCode);
}
Ejemplo n.º 2
0
/*
==============
Sys_ErrorDialog

Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
	char buffer[ 1024 ];
	unsigned int size;
	fileHandle_t f;
	const char *fileName = "crashlog.txt";

	// Shut down now so that the curses console doesn't clear the screen when it's really shut down
	CON_Shutdown( );

	Sys_Print( va( "%s\n", error ) );

	// Write console log to file and to stderr
	f = FS_SV_FOpenFileWrite( fileName );
	if( !f )
	{
		Com_Printf( "ERROR: couldn't open %s\n", fileName );
		return;
	}

	while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
	{
		FS_Write( buffer, size, f );
		fputs( buffer, stderr );
	}

	FS_FCloseFile( f );
}
Ejemplo n.º 3
0
/*
=================
Sys_Exit

Single exit point (regular exit or in case of error)
=================
*/
static __attribute__ ((noreturn)) void Sys_Exit( int exitCode )
{
	CON_Shutdown( );

#ifndef DEDICATED
#ifndef VCMODS_NOSDL
	SDL_Quit( );
#endif
#endif

	if( exitCode < 2 )
	{
		// Normal exit
		char *pidFile = Sys_PIDFileName( );

		if( pidFile != NULL )
			remove( pidFile );
	}

	NET_Shutdown( );

	Sys_PlatformExit( );

	exit( exitCode );
}
Ejemplo n.º 4
0
/* Single exit point (regular exit or in case of error) */
static __attribute__ ((noreturn)) void
Sys_Exit(int exitCode)
{
	CON_Shutdown();
#ifndef DEDICATED
	SDL_Quit();
#endif
	Sys_PlatformExit();
	exit(exitCode);
}
Ejemplo n.º 5
0
/**
 * @brief Single exit point (regular exit or in case of error)
 */
static __attribute__ ((noreturn)) void Sys_Exit(int exitCode)
{
	CON_Shutdown();

#ifndef DEDICATED
	SDL_Quit();
#endif

	// fail safe: delete PID file on abnormal exit
	// FIXME: normal exit pid deletion is done in Com_Shutdown
	//        why do we have 2 locations for this job?
	//        ... is this Com or Sys code?
	if (exitCode > 0)
	{
		// Normal exit
		// com_pidfile does not yet exist on early exit
		if (Cvar_VariableString("com_pidfile")[0] != '\0')
		{
			if (FS_FileExists(Cvar_VariableString("com_pidfile")))
			{
				// FIXME: delete even when outside of homepath
				if (remove(va("%s%c%s%c%s", Cvar_VariableString("fs_homepath"),
				              PATH_SEP, Cvar_VariableString("fs_game"),
				              PATH_SEP, Cvar_VariableString("com_pidfile"))) != 0)
				{
					// This is thrown when game game crashes before PID file is created
					// f.e. when pak files are missing
					// FIXME: try to create PID file earlier
					Com_Printf("Sys_Exit warning - can't delete PID file %s%c%s%c%s\n", Cvar_VariableString("fs_homepath"),
					           PATH_SEP, Cvar_VariableString("fs_game"),
					           PATH_SEP, Cvar_VariableString("com_pidfile"));
				}
				else
				{
					Com_Printf("PID file removed.\n");
				}
			}
			else
			{
				Com_Printf("Sys_Exit warning - PID file doesn't exist %s%c%s%c%s\n", Cvar_VariableString("fs_homepath"),
				           PATH_SEP, Cvar_VariableString("fs_game"),
				           PATH_SEP, Cvar_VariableString("com_pidfile"));
			}
		}
		else
		{
			Com_Printf("Sys_Exit warning no PID file found to remove\n");
		}
	}

	NET_Shutdown();

	exit(exitCode);
}
Ejemplo n.º 6
0
/*
=================
Sys_Exit

Single exit point (regular exit or in case of error)
=================
*/
void Sys_Exit( int ex )
{
	CON_Shutdown( );

#ifndef DEDICATED
	SDL_Quit( );
#endif

#ifdef NDEBUG
	exit( ex );
#else
	// Cause a backtrace on error exits
	assert( ex == 0 );
	exit( ex );
#endif
}
Ejemplo n.º 7
0
/*
=================
Sys_Exit

Single exit point (regular exit or in case of error)
=================
*/
static void Sys_Exit( int exitCode )
{
	CON_Shutdown( );

#ifndef DEDICATED
	SDL_Quit( );
#endif

	if( exitCode < 2 )
	{
		// Normal exit
		remove( Sys_PIDFileName( ) );
	}

	exit( exitCode );
}
/*
=================
Sys_Exit

Single exit point (regular exit or in case of error)
=================
*/
static __attribute__ ((noreturn)) void Sys_Exit( int exitCode ) {

	CON_Shutdown();
	// we may be exiting to spawn another process
	if ( exit_cmdline[0] != '\0' ) {
		// possible race conditions?
		// buggy kernels / buggy GL driver, I don't know for sure
		// but it's safer to wait an eternity before and after the fork
		Sys_SleepSec( 1 );
		Sys_ReplaceProcess( exit_cmdline );
		Sys_SleepSec( 1 );
	}

	// We can't do this
	// as long as GL DLL's keep installing with atexit...
	Sys_ExitForOS( exitCode );
}
Ejemplo n.º 9
0
static void NORETURN Sys_Exit( int ex ) {
	IN_Shutdown();
#ifndef DEDICATED
	SDL_Quit();
#endif

	NET_Shutdown();

	Sys_PlatformExit();

	Com_ShutdownHunkMemory();
	Com_ShutdownZoneMemory();

	CON_Shutdown();

    exit( ex );
}
Ejemplo n.º 10
0
/*
=================
Sys_Exit

Single exit point (regular exit or in case of error)
=================
*/
void __attribute__ ((noreturn)) Sys_Exit( int ex )
{
	CON_Shutdown( );

#ifndef DEDICATED
	SDL_Quit( );
#endif

	NET_Shutdown( );

	Sys_PlatformExit();

#ifdef NQDEBUG
	exit( ex );
#else
	// Cause a backtrace on error exits
	assert( ex == 0 );
	exit( ex );
#endif
}
Ejemplo n.º 11
0
/*
=================
Sys_Exit

Single exit point (regular exit or in case of error)
=================
*/
static __attribute__ ((noreturn)) void Sys_Exit( int exitCode )
{
	CON_Shutdown( );

#ifndef DEDICATED
	SDL_Quit( );
#endif

	if( exitCode < 2 && com_fullyInitialized )
	{
		// Normal exit
		Sys_RemovePIDFile( FS_GetCurrentGameDir() );
	}

	NET_Shutdown( );

	Sys_PlatformExit( );

	exit( exitCode );
}
Ejemplo n.º 12
0
/*
 * @brief Single exit point (regular exit or in case of error)
 */
static __attribute__ ((noreturn)) void Sys_Exit(int exitCode)
{
	CON_Shutdown();

#ifndef DEDICATED
	SDL_Quit();
#endif

	if (exitCode < 2)
	{
		// Normal exit
		char *pidFile = Sys_PIDFileName();

		if (pidFile != NULL)
		{
			remove(pidFile);
		}
	}

	exit(exitCode);
}