예제 #1
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;
}
예제 #2
0
파일: main.c 프로젝트: icanhas/yantar
void
sysinit(void)
{
	char pidbuf[16];

	cmdadd("in_restart", Sys_In_Restart_f);
	cvarsetstr("arch", OS_STRING " " ARCH_STRING);
	cvarsetstr("username", sysgetcurrentuser());
	Q_sprintf(pidbuf, sizeof(pidbuf), "%d", Sys_PID());
	cvarget("pid", pidbuf, CVAR_ROM);
	cvarsetdesc("pid", "process ID, for debugging purposes");
}