Example #1
0
/*
=======================================================================================================================================
Sys_StartProcess

Starts process.

cmdline - Execution string.
doexit - Quit from game after executing command.

If !doexit then start the process ASAP, otherwise push it for execution at exit (i.e. let complete shutdown of the game and freeing of
resources happen).

NOTE: might even want to add a small delay?
=======================================================================================================================================
*/
void Sys_StartProcess(char *cmdline, qboolean doexit) {

	if (doexit) {
		Com_DPrintf("Sys_StartProcess %s(delaying to final exit)\n", cmdline);
		Sys_DoStartProcess(cmdline);
		Cbuf_ExecuteText(EXEC_APPEND, "quit\n");
		return;
	}

	Com_DPrintf("Sys_StartProcess %s\n", cmdline);
	Sys_DoStartProcess(cmdline);
}
Example #2
0
/*
================
Posix_Exit
================
*/
void Posix_Exit( int ret )
{
	if( tty_enabled )
	{
		Sys_Printf( "shutdown terminal support\n" );
		if( tcsetattr( 0, TCSADRAIN, &tty_tc ) == -1 )
		{
			Sys_Printf( "tcsetattr failed: %s\n", strerror( errno ) );
		}
	}
	// at this point, too late to catch signals
	Posix_ClearSigs();
	
	//if( asyncThread.threadHandle )
	//{
	//	Sys_DestroyThread( asyncThread );
	//}
	
	// process spawning. it's best when it happens after everything has shut down
	if( exit_spawn[0] )
	{
		Sys_DoStartProcess( exit_spawn, false );
	}
	// in case of signal, handler tries a common->Quit
	// we use set_exit to maintain a correct exit code
	if( set_exit )
	{
		exit( set_exit );
	}
	exit( ret );
}
Example #3
0
// single exit point (regular exit or in case of signal fault)
void Sys_Exit( int ex ) {
	Sys_ConsoleInputShutdown();

	// we may be exiting to spawn another process
	if ( exit_cmdline[ 0 ] != '\0' ) {
		// temporize, it seems if you spawn too fast before GL is released, or if you exit too fast after the fork
		// some kernel can panic (my 2.4.17 does)
		sleep( 1 );
		Sys_DoStartProcess( exit_cmdline );
		sleep( 1 );
	}

#ifdef NDEBUG	// regular behavior

	// We can't do this
	//  as long as GL DLL's keep installing with atexit...
	//exit(ex);
	_exit( ex );
#else

	// Give me a backtrace on error exits.
	assert( ex == 0 );
	exit( ex );
#endif
}
Example #4
0
/*
====================
SV_StopRecord

stop recording a demo
====================
*/
void SV_StopRecord( client_t *cl ) {
	int len;
	byte null;
	static char cmdline[1024];

	if ( !cl->demorecording ) {
		Com_Printf( "Not recording a demo.\n" );
		return;
	}
	// finish up

	null = 0;

	FS_DemoWrite( &null, 1, &cl->demofile );

	len = -1;

	FS_DemoWrite( &len, 4, &cl->demofile );
	FS_DemoWrite( &len, 4, &cl->demofile );

	FS_FCloseDemoFile( &cl->demofile );
	cl->demorecording = qfalse;
	Com_Printf( "Stopped demo for: %s\n", cl->name);

	if(!*sv_demoCompletedCmd->string)
		return;

	Com_sprintf(cmdline, sizeof(cmdline), "\"%s/%s\" \"%s/%s\"", fs_homepath->string, sv_demoCompletedCmd->string, fs_homepath->string, cl->demoName);

	Sys_DoStartProcess(cmdline);

	Sys_TermProcess();

}
Example #5
0
// single exit point (regular exit or in case of signal fault)
void Sys_Exit( int ex ) {
	Sys_ConsoleInputShutdown();

	// 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
		sleep( 1 );
		Sys_DoStartProcess( exit_cmdline );
		sleep( 1 );
	}

#ifdef NDEBUG // regular behavior

	// We can't do this
	//  as long as GL DLL's keep installing with atexit...
	//exit(ex);
	_exit( ex );
#else

	// Give me a backtrace on error exits.
	assert( ex == 0 );
	exit( ex );
#endif
}
/*
==================
idSysLocal::StartProcess
if !quit, start the process asap
otherwise, push it for execution at exit
(i.e. let complete shutdown of the game and freeing of resources happen)
NOTE: might even want to add a small delay?
==================
*/
void idSysLocal::StartProcess( const char *exeName, bool quit ) {
	if ( quit ) {
		common->DPrintf( "Sys_StartProcess %s (delaying until final exit)\n", exeName );
		Posix_SetExitSpawn( exeName );
		cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "quit\n" );
		return;
	}

	common->DPrintf( "Sys_StartProcess %s\n", exeName );
	Sys_DoStartProcess( exeName );
}
Example #7
0
/*
==================
Sys_StartProcess
if !doexit, start the process asap
otherwise, push it for execution at exit
(i.e. let complete shutdown of the game and freeing of resources happen)
NOTE: might even want to add a small delay?
==================
*/
void Sys_StartProcess( char *cmdline, qboolean doexit ) {

	if ( doexit ) {
		Com_DPrintf( "Sys_StartProcess %s (delaying to final exit)\n", cmdline );
		Q_strncpyz( exit_cmdline, cmdline, MAX_CMD );
		Cbuf_ExecuteText( EXEC_APPEND, "quit" );
	}

	Cbuf_ExecuteText( EXEC_NOW, "net_stop" );
	Com_DPrintf( "Sys_StartProcess %s\n", cmdline );
	Sys_DoStartProcess( cmdline );
}
Example #8
0
File: sys_main.c Project: dioda/apb
/*
=================
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
		sleep( 1 );
		Sys_DoStartProcess( exit_cmdline );
		sleep( 1 );
	}

	// We can't do this
	//  as long as GL DLL's keep installing with atexit...
	//exit(ex);
	exit( exitCode );
}