Example #1
0
static void signal_handler( int sig )
{
	static int try = 0;

	switch( try++ )
	{
	case 0:
		if( sig == SIGINT || sig == SIGTERM )
		{
			Com_Printf( "Received signal %d, exiting...\n", sig );
			Com_Quit();
		}
		else
		{
			Com_Error( ERR_FATAL, "Received signal %d\n", sig );
		}
		break;
	case 1:
#ifndef DEDICATED_ONLY
		printf( "Received signal %d, exiting...\n", sig );
		CL_Shutdown();
		_exit( 1 );
		break;
	case 2:
#endif
		printf( "Received signal %d, exiting...\n", sig );
		_exit( 1 );
		break;

	default:
		_exit( 1 );
		break;
	}
}
Example #2
0
void Sys_Error(char *error, ...)
{
  va_list argptr;
  char text[1024];

#ifndef DEDICATED_ONLY
  CL_Shutdown();
#endif

  Qcommon_Shutdown();

  va_start(argptr, error);
  vsprintf(text, error, argptr);
  va_end(argptr);
  fprintf(stderr, "Error: %s\n", text);

  MessageBox(NULL, text, "Error", 0 /* MB_OK */);

  if (qwclsemaphore) {
    CloseHandle(qwclsemaphore);
  }

  /* Close stdout and stderr */
#ifndef DEDICATED_ONLY
  fclose(stdout);
  fclose(stderr);
#endif

  exit(1);
}
Example #3
0
void
Sys_Quit(void)
{
	timeEndPeriod(1);

#ifndef DEDICATED_ONLY
	CL_Shutdown();
#endif

	Qcommon_Shutdown();
	CloseHandle(qwclsemaphore);

	if (dedicated && dedicated->value)
	{
		FreeConsole();
	}

	/* Close stdout and stderr */
#ifndef DEDICATED_ONLY
	fclose(stdout);
	fclose(stderr);
#endif

	exit(0);
}
Example #4
0
/*
=================
Sys_SigHandler
=================
*/
void Sys_SigHandler( int signal )
{
	static qboolean signalcaught = qfalse;

	//Com_Printf("signal: %d\n", signal);
	if( signalcaught )
	{
		fprintf( stderr, "DOUBLE SIGNAL FAULT: Received signal %d, exiting...\n",
			signal );
	}
	else
	{
		signalcaught = qtrue;
		VM_Forced_Unload_Start();
		fprintf( stderr, "Received signal %d, exiting...\n", signal );

#ifndef DEDICATED
		CL_Shutdown();
#endif
		SV_Shutdown( "Signal caught" );
		VM_Forced_Unload_Done();
	}

	Sys_Exit( 0 ); // Exit with 0 to avoid recursive signals
}
Example #5
0
//FIXME: this is a callback from Sys_Quit and Sys_Error.  It would be better
//to run quit through here before the final handoff to the sys code.
void Host_Shutdown (void)
{
	static qbool isdown = false;

	if (isdown) {
		printf ("recursive shutdown\n");
		return;
	}
	isdown = true;

	// on low-end systems quit process may last long time (was about 1 minute for me on old compo),
	// at the same time may repeats repeats repeats some sounds, trying preventing this
	S_StopAllSounds (true);
	S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);

	SV_Shutdown ("Server quit\n");

#if (!defined WITH_PNG_STATIC && !defined WITH_JPEG_STATIC)
	QLib_Shutdown();
#endif

	CL_Shutdown ();
	NET_Shutdown ();
	Con_Shutdown();
#ifdef WITH_TCL
	TCL_Shutdown ();
#endif
	qtvlist_deinit();
}
Example #6
0
/*
* Com_Quit
* 
* Both client and server can use this, and it will
* do the apropriate things.
*/
void Com_Quit( void )
{
	if( dynvars_initialized )
	{
		dynvar_t *quit = Dynvar_Lookup( "quit" );
		if( quit )
		{
			// wsw : aiwa : added "quit" event for pluggable clean-up (e.g. IRC shutdown)
			Dynvar_CallListeners( quit, NULL );
		}
		Dynvar_Destroy( quit );
	}

	SV_Shutdown( "Server quit\n" );
	CL_Shutdown();
	MM_Shutdown();

	if( log_file )
	{
		FS_FCloseFile( log_file );
		log_file = 0;
	}

	Sys_Quit();
}
Example #7
0
void Sys_Quit (void)
{
	CL_Shutdown ();
	Qcommon_Shutdown ();
    fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
	_exit(0);
}
Example #8
0
/*
* Sys_Error
*/
void Sys_Error( const char *format, ... )
{
	static qboolean	recursive = qfalse;
	va_list	argptr;
	char string[1024];

	// change stdin to non blocking
	fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) & ~FNDELAY );

	va_start( argptr, format );
	Q_vsnprintfz( string, sizeof( string ), format, argptr );
	va_end( argptr );

	if( recursive )
	{
		fprintf( stderr, "Recursive Sys_Error: %s\n", string );
		_exit( 1 );
	}

	recursive = qtrue;

	fprintf( stderr, "Error: %s\n", string );

	CL_Shutdown();
	Qcommon_Shutdown();

	_exit( 1 );
}
Example #9
0
/*
=================
Sys_SigHandler
=================
*/
void Sys_SigHandler( int signal )
{
	static qboolean signalcaught = qfalse;

	if( signalcaught )
	{
		fprintf( stderr, "DOUBLE SIGNAL FAULT: Received signal %d, exiting...\n",
			signal );
	}
	else
	{
		signalcaught = qtrue;
		VM_Forced_Unload_Start();
#ifndef DEDICATED
		CL_Shutdown(va("Received signal %d", signal), qtrue, qtrue);
#endif
		SV_Shutdown(va("Received signal %d", signal) );
		VM_Forced_Unload_Done();
	}

	if( signal == SIGTERM || signal == SIGINT )
		Sys_Exit( 1 );
	else
		Sys_Exit( 2 );
}
Example #10
0
void Sys_Quit (void) {
	CL_Shutdown ();
//	int on = 1;
//	setsockopt(0, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int));

//jens	fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
	Sys_Exit(0);
}
Example #11
0
/*
=============
Com_Quit_f

Both client and server can use this, and it will
do the apropriate things.
=============
*/
void Com_Quit_f( void ) {
	// don't try to shutdown if we are in a recursive error
	if ( !com_errorEntered ) {
		SV_Shutdown ("Server quit\n");
		CL_Shutdown ();
		Com_Shutdown ();
	}
	Sys_Quit ();
}
Example #12
0
int main(int argc, char *argv[] )
{
  CL_SimplexSolver solver;
  CLV frameWidth;
  CLV frameHeight;
  CLV x;
  CLV y;
  CL_Constraint cn;

  CL_Init();

  CL_SetVarMap(CL_VarMapNew());
  solver = CL_SimplexSolverNew();
  frameWidth = CL_vNew("frameWidth",577,solver);
  frameHeight = CL_vNew("frameHeight",651,solver);
  CL_SimplexSolverAddStrongStay(solver,frameWidth,10);
  CL_SimplexSolverAddStrongStay(solver,frameHeight,10);
  x = CL_vNew("x",0,solver);
#ifdef CL_BUILD_FD_SOLVER 
  y = CL_dvNew("y",4,6,9,15,20,FDN_EOL);
#else
  y = CL_vNew("y",4, solver);
#endif  
  CL_vPrint(x,stdout);
  printf("\n");
  CL_vPrint(y,stdout);
  printf("\n");
 
  printf("x = %g, frameWidth = %g\n",CL_vValue(x),CL_vValue(frameWidth));

  cn = CL_ParseConstraint("x = frameWidth/3", "strong");
  printf("x = %g, frameWidth = %g\n",CL_vValue(x),CL_vValue(frameWidth));

  CL_AddConstraint(solver,cn);
  printf("x = %g, frameWidth = %g\n",CL_vValue(x),CL_vValue(frameWidth));

  CL_Solve(solver);
  printf("x = %g, frameWidth = %g\n",CL_vValue(x),CL_vValue(frameWidth));

  printf("\"x\" has Value %g\n", CL_vValue(CL_vLookup("x")));

  CL_SolverPrint(solver,stderr);

  CL_SimplexSolverSetEditedValue(solver,frameWidth,620);
  printf("x = %g, frameWidth = %g\n",CL_vValue(x),CL_vValue(frameWidth));

  CL_SolverPrint(solver,stderr);

  printf("x = %g, frameWidth = %g\n",CL_vValue(x),CL_vValue(frameWidth));

  CL_SimplexSolverSetEditedValue(solver,frameWidth,700);
  printf("x = %g, frameWidth = %g\n",CL_vValue(x),CL_vValue(frameWidth));

  CL_TableauPrintExternalVariables(solver,stderr);
  CL_Shutdown();
  return 0;
}
Example #13
0
/*
 * Both client and server can use this, and it will
 * do the apropriate things.
 */
void
Com_Error(int code, char *fmt, ...)
{
	va_list argptr;
	static char msg[MAXPRINTMSG];
	static qboolean recursive;

	if (recursive)
	{
		Sys_Error("recursive error after: %s", msg);
	}

	recursive = true;

	va_start(argptr, fmt);
	vsnprintf(msg, MAXPRINTMSG, fmt, argptr);
	va_end(argptr);

	if (code == ERR_DISCONNECT)
	{
#ifndef DEDICATED_ONLY
		CL_Drop();
#endif
		recursive = false;
		longjmp(abortframe, -1);
	}

	else if (code == ERR_DROP)
	{
		Com_Printf("********************\nERROR: %s\n********************\n",
				msg);
		SV_Shutdown(va("Server crashed: %s\n", msg), false);
#ifndef DEDICATED_ONLY
		CL_Drop();
#endif
		recursive = false;
		longjmp(abortframe, -1);
	}

	else
	{
		SV_Shutdown(va("Server fatal crashed: %s\n", msg), false);
#ifndef DEDICATED_ONLY
		CL_Shutdown();
#endif
	}

	if (logfile)
	{
		fclose(logfile);
		logfile = NULL;
	}

	Sys_Error("%s", msg);
	recursive = false;
}
Example #14
0
void QDECL Com_Error( int code, const char *fmt, ... ) {
	va_list		argptr;

	// when we are running automated scripts, make sure we
	// know if anything failed
	if ( com_buildScript && com_buildScript->integer ) {
		code = ERR_FATAL;
	}

	if ( com_errorEntered ) {
		Sys_Error( "recursive error after: %s", com_errorMessage );
	}
	
	com_errorEntered = qtrue;

	//reset some game stuff here
//	SCR_UnprecacheScreenshot();

	va_start (argptr,fmt);
	Q_vsnprintf (com_errorMessage, sizeof(com_errorMessage), fmt, argptr);
	va_end (argptr);	

	if ( code != ERR_DISCONNECT ) {
		Cvar_Get("com_errorMessage", "", CVAR_ROM);	//give com_errorMessage a default so it won't come back to life after a resetDefaults
		Cvar_Set("com_errorMessage", com_errorMessage);
	}

	SG_Shutdown();				// close any file pointers
	if ( code == ERR_DISCONNECT ) {
		SV_Shutdown("Disconnect", qtrue);
		CL_Disconnect();
		CL_FlushMemory();
		CL_StartHunkUsers();
		com_errorEntered = qfalse;
		throw ("DISCONNECTED\n");
	} else if ( code == ERR_DROP ) {
		// If loading/saving caused the crash/error - delete the temp file
		SG_WipeSavegame("current");	// delete file

		SV_Shutdown (va("Server crashed: %s\n",  com_errorMessage), qtrue);
		CL_Disconnect();
		CL_FlushMemory();
		CL_StartHunkUsers();
		Com_Printf (S_COLOR_RED"********************\n"S_COLOR_MAGENTA"ERROR: %s\n"S_COLOR_RED"********************\n", com_errorMessage);
		com_errorEntered = qfalse;
		throw ("DROPPED\n");
	} else {
		CL_Shutdown ();
		SV_Shutdown (va(S_COLOR_RED"Server fatal crashed: %s\n", com_errorMessage), qtrue);
	}

	Com_Shutdown ();

	Sys_Error ("%s", com_errorMessage);
}
Example #15
0
jint EXPORT_ME
Java_com_jeyries_quake2_Quake2_Quake2Quit( JNIEnv* env,
                                                  jobject thiz )
{
	//Sys_Quit();
	CL_Shutdown ();
	Qcommon_Shutdown ();
	//fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
	// 	_exit(0);
	return 0;
}
Example #16
0
void NORETURN QDECL Com_Error( int code, const char *fmt, ... ) {
	va_list		argptr;
	static int	lastErrorTime;
	static int	errorCount;
	int			currentTime;

	if ( com_errorEntered ) {
		Sys_Error( "recursive error after: %s", com_errorMessage );
	}
	com_errorEntered = qtrue;

	// when we are running automated scripts, make sure we
	// know if anything failed
	if ( com_buildScript && com_buildScript->integer ) {
		code = ERR_FATAL;
	}

	// if we are getting a solid stream of ERR_DROP, do an ERR_FATAL
	currentTime = Sys_Milliseconds();
	if ( currentTime - lastErrorTime < 100 ) {
		if ( ++errorCount > 3 ) {
			code = ERR_FATAL;
		}
	} else {
		errorCount = 0;
	}
	lastErrorTime = currentTime;

#ifdef JK2_MODE
	SCR_UnprecacheScreenshot();
#endif
	
	va_start (argptr,fmt);
	Q_vsnprintf (com_errorMessage, sizeof(com_errorMessage), fmt, argptr);
	va_end (argptr);	

	if ( code != ERR_DISCONNECT ) {
		Cvar_Get("com_errorMessage", "", CVAR_ROM);	//give com_errorMessage a default so it won't come back to life after a resetDefaults
		Cvar_Set("com_errorMessage", com_errorMessage);
	}

	SG_Shutdown();	// close any file pointers
	if ( code == ERR_DISCONNECT || code == ERR_DROP ) {
		throw code;
	} else {
		SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage));
		CL_Shutdown ();
	}

	Com_Shutdown ();

	Sys_Error ("%s", com_errorMessage);
}
Example #17
0
void Sys_Quit (void)
{
	timeEndPeriod( 1 );

	CL_Shutdown();
	Qcommon_Shutdown ();
	CloseHandle (qwclsemaphore);
	if (dedicated && dedicated->value)
		FreeConsole ();

	exit (0);
}
Example #18
0
void Sys_Quit (void)
{
	timeEndPeriod( 1 );

	CL_Shutdown();

	Qcommon_Shutdown();

	Sys_DestroyConsole();

	exit (0);
}
Example #19
0
/*
=============
Com_Quit

Both client and server can use this, and it will
do the apropriate things.
=============
*/
void Com_Quit (void)
{
	SV_Shutdown ("Server quit\n", false);
	CL_Shutdown ();

	if (logfile) {
		fclose (logfile);
		logfile = NULL;
	}

	Sys_Quit ();
}
Example #20
0
/**
 * @brief
 * @sa Qcommon_Shutdown
 */
void Sys_Quit (void)
{
#ifdef COMPILE_UFO
	CL_Shutdown();
	Qcommon_Shutdown();
	Sys_ConsoleShutdown();
#elif COMPILE_MAP
	Mem_Shutdown();
#endif

	fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) & ~FNDELAY);
	exit(0);
}
Example #21
0
void Sys_Quit (void)
{
	timeEndPeriod(1);

#ifdef COMPILE_UFO
	CL_Shutdown();
	Qcommon_Shutdown();
#elif COMPILE_MAP
	Mem_Shutdown();
#endif

	/* exit(0) */
	ExitProcess(0);
}
Example #22
0
/*
=================
Sys_Error
=================
*/
void Sys_Error( const char *error, ... )
{
	va_list argptr;
	char    string[1024];

	va_start (argptr,error);
	Q_vsnprintf (string, sizeof(string), error, argptr);
	va_end (argptr);

	CL_Shutdown( string );
	Sys_ErrorDialog( string );

	Sys_Exit( 3 );
}
Example #23
0
/*
=============
Com_Error

Both client and server can use this, and it will
do the apropriate things.
=============
*/
void Com_Error (int code, char *fmt, ...)
{
	va_list argptr;
	static char msg[MAXPRINTMSG];
	static qboolean recursive;

//	assert(Q_streq(fmt, "Disconnected from server")); // jitdebug

	if (recursive)
		Sys_Error("Recursive error after: %s", msg);

	recursive = true;
	va_start(argptr,fmt);
	_vsnprintf(msg, sizeof(msg), fmt, argptr); // jitsecurity -- prevent buffer overruns
	va_end(argptr);
	NULLTERMINATE(msg); // jitsecurity -- make sure string is null terminated.

	switch (code) // jiterror
	{
	case ERR_BENIGN: // jiterror - don't close the app.  Just print the error to the console.
		Com_Printf("*** ERROR: %s\n", msg);
		recursive = false;
		return;
	case ERR_DISCONNECT:
		CL_Drop();
		recursive = false;
		longjmp(abortframe, -1);
		break;
	case ERR_DROP:
		Com_Printf("********************\nERROR: %s\n********************\n", msg);
		SV_Shutdown(va("Server crashed: %s\n", msg), false);
		CL_Drop();
		recursive = false;
		longjmp(abortframe, -1);
		break;
	case ERR_FATAL:
	default:
		SV_Shutdown(va("Server fatal crashed: %s\n", msg), false);
		CL_Shutdown();
	}

	if (logfile)
	{
		fclose(logfile);
		logfile = NULL;
	}

	Sys_Error("%s", msg);
}
Example #24
0
void Sys_Quit (void)
{
	timeEndPeriod( 1 );

	CL_Shutdown();
	Qcommon_Shutdown ();
	CloseHandle (qwclsemaphore);
	if (dedicated && dedicated->value)
		FreeConsole ();

// shut down QHOST hooks if necessary
	DeinitConProc ();

	exit (0);
}
Example #25
0
File: host.c Project: matatk/agrip
/*
===============
Host_Shutdown

FIXME: this is a callback from Sys_Quit and Sys_Error.  It would be better
to run quit through here before the final handoff to the sys code.
===============
*/
void Host_Shutdown (void)
{
	static qbool isdown = false;
	
	if (isdown)
	{
		printf ("recursive shutdown\n");
		return;
	}
	isdown = true;

	SV_Shutdown ("Server quit\n");
	CL_Shutdown ();
	NET_Shutdown ();
	COM_Shutdown ();
}
Example #26
0
/**
 * @note Both client and server can use this, and it will
 * do the appropriate things.
 */
void Com_Error (int code, const char* fmt, ...)
{
	va_list argptr;
	static char msg[MAXPRINTMSG];
	static bool recursive = false;

	if (recursive)
		Sys_Error("recursive error after: %s", msg);
	recursive = true;

	va_start(argptr, fmt);
	Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
	va_end(argptr);

	switch (code) {
	case ERR_DISCONNECT:
		Com_Printf("%s\n", msg);
		CL_Drop();
		recursive = false;
		Com_Drop();
	case ERR_DROP:
		Com_Printf("********************\n");
		Com_Printf("ERROR: %s\n", msg);
		Com_Printf("********************\n");
		Sys_Backtrace();
		SV_Shutdown("Server crashed.", false);
		CL_Drop();
		recursive = false;
		Com_Drop();
	default:
		Com_Printf("%s\n", msg);
		SV_Shutdown("Server fatal crashed", false);

		/* send an receive net messages a last time */
		NET_Wait(0);

		FS_CloseFile(&logfile);
		if (pipefile.f != nullptr) {
			FS_CloseFile(&pipefile);
			FS_RemoveFile(va("%s/%s", FS_Gamedir(), pipefile.name));
		}

		CL_Shutdown();
		Qcommon_Shutdown();
		Sys_Error("Shutdown");
	}
}
Example #27
0
void	Sys_Error( const char *error, ...)
{ 
    va_list     argptr;
    char        string[1024];

	// change stdin to non blocking
    fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);

    CL_Shutdown ();
    
    va_start (argptr,error);
    vsprintf (string,error,argptr);
    va_end (argptr);
    fprintf(stderr, "Sys_Error: %s\n", string);
    
    Sys_Exit( 1 ); // bk010104 - use single exit point.
} 
Example #28
0
void Sys_Error( const char *format, ... )
{
    va_list argptr;
    char msg[1024];

    CL_Shutdown();

    va_start( argptr, format );
    Q_vsnprintfz( msg, sizeof( msg ), format, argptr );
    va_end( argptr );

    SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, APPLICATION, msg, NULL );

    Qcommon_Shutdown();

    exit( 1 );
}
Example #29
0
void Sys_Quit( void )
{
	timeEndPeriod( 1 );

	SV_Shutdown( "Server quit\n" );
	CL_Shutdown();

	if( dedicated && dedicated->integer )
		FreeConsole();

	// shut down QHOST hooks if necessary
	DeinitConProc();

	Qcommon_Shutdown();

	exit( 0 );
}
Example #30
0
void Sys_Error(char *error, ...){
	va_list argptr;
	char string[1024];
	
	/* change stdin to non blocking */
	fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~FNDELAY);
	
	CL_Shutdown();
	Qcommon_Shutdown();
	
	va_start(argptr, error);
	vsnprintf(string, 1024, error, argptr);
	va_end(argptr);
	fprintf(stderr, "Error: %s\n", string);
	
	_exit(1);
}