Example #1
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 );
}
Example #2
0
/*
=================
Sys_WritePIDFile

Return qtrue if there is an existing stale PID file
=================
*/
qboolean Sys_WritePIDFile( void )
{
	char      *pidFile = Sys_PIDFileName( );
	FILE      *f;
	qboolean  stale = qfalse;

	// First, check if the pid file is already there
	if( ( f = fopen( pidFile, "r" ) ) != NULL )
	{
		char  pidBuffer[ 64 ] = { 0 };
		int   pid;

		fread( pidBuffer, sizeof( char ), sizeof( pidBuffer ) - 1, f );
		fclose( f );

		pid = atoi( pidBuffer );
		if( !Sys_PIDIsRunning( pid ) )
			stale = qtrue;
	}

	if( ( f = fopen( pidFile, "w" ) ) != NULL )
	{
		fprintf( f, "%d", Sys_PID( ) );
		fclose( f );
	}
	else
		Com_Printf( S_COLOR_YELLOW "Couldn't write %s.\n", pidFile );

	return stale;
}
Example #3
0
/*
=================
Sys_RemovePIDFile
=================
*/
void Sys_RemovePIDFile( const char *gamedir )
{
	char *pidFile = Sys_PIDFileName( gamedir );

	if( pidFile != NULL )
		remove( pidFile );
}
Example #4
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 );
}
Example #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

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

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

	exit(exitCode);
}