/* ================= Sys_DoSignalAction ================= */ void Sys_DoSignalAction( int signal, const char* sigstring ) { static qboolean signalcaught = qfalse; char termmsg[MAX_STRING_CHARS]; Com_Printf( "Received signal: %s, exiting...\n", sigstring ); if( signalcaught ) { Com_Printf( "DOUBLE SIGNAL FAULT: Received signal: %s, exiting...\n", sigstring); } else { signalcaught = qtrue; Com_Printf("Server received signal: %s\nShutting down server...\n", sigstring); Com_sprintf(termmsg, sizeof(termmsg), "\nServer received signal: %s\nTerminating server...", sigstring); SV_Shutdown( termmsg ); Sys_EnterCriticalSection( 2 ); Com_CloseLogFiles(); //close all open logfiles FS_Shutdown(qtrue); } if( signal == SIGTERM || signal == SIGINT ) Sys_Exit( 1 ); else Sys_Exit( 2 ); }
/* ================ Sys_Error ================ */ void Sys_Error (const char *error, ...) { static qbool inerror = false; va_list argptr; char text[1024]; sv_error = true; if (inerror) Sys_Exit (1); inerror = true; va_start (argptr,error); vsnprintf (text, sizeof(text), error, argptr); va_end (argptr); if (!(int)sys_nostdout.value) Sys_Printf ("ERROR: %s\n", text); if (logs[ERROR_LOG].sv_logfile) { SV_Write_Log (ERROR_LOG, 1, va ("ERROR: %s\n", text)); // fclose (logs[ERROR_LOG].sv_logfile); } // FIXME: hack - checking SV_Shutdown with net_socket set in -1 NET_Shutdown if (svs.socketip != -1) SV_Shutdown (va("ERROR: %s\n", text)); if ((int)sys_restart_on_error.value) Sys_Quit (true); Sys_Exit (1); }
void Sys_SigHandler(int signal) { static qbool signalcaught = qfalse; const char *name; name = signame(signal); fprintf(stderr, "GOOFED: received signal %d (%s)", signal, name); if(signalcaught) fprintf(stderr, "DOUBLE SIGNAL FAULT: received signal %d (%s), exiting...\n", signal, name); else{ signalcaught = qtrue; vmsetforceunload(); if(!com_dedicated->integer) clshutdown(va("received signal %d (%s)", signal, name), qtrue, qtrue); svshutdown(va("received signal %d (%s)", signal, name)); vmclearforceunload(); } fflush(stdout); fflush(stderr); if(signal == SIGTERM || signal == SIGINT) Sys_Exit(1); else Sys_Exit(2); }
/* ================= Sys_SigHandler ================= */ void Sys_SigHandler( int signal ) { static qboolean signalcaught = qfalse; fprintf( stderr, "Received signal: %s, exiting...\n", strsignal(signal) ); if( signalcaught ) { fprintf( stderr, "DOUBLE SIGNAL FAULT: Received signal: %s, exiting...\n", strsignal(signal)); } else { signalcaught = qtrue; Com_Printf("Server received signal: %s\nShutting down server...", strsignal(signal)); SV_Shutdown(va("\nServer received signal: %s\nTerminating server...", strsignal(signal)) ); Sys_EnterCriticalSection( 2 ); if(logfile) FS_FCloseFile(logfile); if(adminlogfile) FS_FCloseFile(adminlogfile); if(reliabledump) FS_FCloseFile(reliabledump); FS_Shutdown(qtrue); } if( signal == SIGTERM || signal == SIGINT ) Sys_Exit( 1 ); else Sys_Exit( 2 ); }
void Sys_Quit (qbool restart) { if (restart) { #ifndef __MINGW32__ int maxfd = 131072; // well, should be enough for everyone... _set_invalid_parameter_handler(myInvalidParameterHandler); // so close() does not crash our program on invalid handle... // close all file descriptors even stdin stdout and stderr, seems that not hurt... for (; maxfd > -1; maxfd--) { close(maxfd); closesocket(maxfd); // yeah, windows separate sockets and files, so you can't close socket with close() like on *nix. } if (execv(argv[0], com_argv) == -1) #endif { #ifdef _CONSOLE if (!((int)sys_nostdout.value || isdaemon)) printf("Restart failed: (%i): %s\n", qerrno, strerror(qerrno)); #else if (!(COM_CheckParm("-noerrormsgbox") || isdaemon)) MessageBox(NULL, strerror(qerrno), "Restart failed", 0 /* MB_OK */ ); #endif Sys_Exit(1); } } Sys_Exit(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; #ifndef DEDICATED CL_Shutdown(); #endif SV_Shutdown(va("Received signal %d", signal)); } if (signal == SIGTERM || signal == SIGINT) { Sys_Exit(1); } else { Sys_Exit(2); } }
static void signal_handler( int sig ) { if ( signalcaught ) { printf( "DOUBLE SIGNAL FAULT: Received signal %d, exiting...\n", sig ); Sys_Exit( 1 ); } signalcaught = qtrue; printf( "Received signal %d, exiting...\n", sig ); GLimp_Shutdown(); Sys_Exit( 0 ); }
static void signal_handler(int sig) // bk010104 - replace this... { if (signalcaught) { printf("DOUBLE SIGNAL FAULT: Received signal %d, exiting...\n", sig); Sys_Exit(1); // bk010104 - abstraction } signalcaught = qtrue; printf("Received signal %d, exiting...\n", sig); GLimp_Shutdown(); // bk010104 - shouldn't this be CL_Shutdown Sys_Exit(1); // bk010104 - abstraction }
static void signal_handler(int sig) {// bk010104 - replace this... (NOTE TTimo huh?) if (signalcaught) { printf("DOUBLE SIGNAL FAULT: Received signal %d, exiting...\n", sig); Sys_Exit(1); // bk010104 - abstraction } signalcaught = qtrue; printf("Received signal %d, exiting...\n", sig); #ifndef DEDICATED GLimp_Shutdown(); // bk010104 - shouldn't this be CL_Shutdown #endif Sys_Exit(0); // bk010104 - abstraction NOTE TTimo send a 0 to avoid DOUBLE SIGNAL FAULT }
void Sys_Error( const char* error, ... ) { va_list argptr; char string[ 1024 ]; // change stdin to non blocking // NOTE TTimo not sure how well that goes with tty console mode fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) & ~FNDELAY ); // don't bother do a show on this one heh if ( ttycon_on ) { tty_Hide(); } va_start( argptr,error ); Q_vsnprintf( string, sizeof ( string ), error, argptr ); va_end( argptr ); fprintf( stderr, "Sys_Error: %s\n", string ); if ( GGameType & GAME_QuakeHexen ) { ComQH_HostShutdown(); } else { CL_Shutdown(); } Sys_Exit( 1 ); // bk010104 - use single exit point. }
/* ================= Sys_ParseArgs ================= */ void Sys_ParseArgs( int argc, char **argv ) { #if defined(USE_CURSES) || !defined(_WIN32) int i; #endif if( argc == 2 ) { if( !strcmp( argv[1], "--version" ) || !strcmp( argv[1], "-v" ) ) { const char* date = __DATE__; #ifdef DEDICATED fprintf( stdout, Q3_VERSION " dedicated server (%s)\n", date ); #else fprintf( stdout, Q3_VERSION " client (%s)\n", date ); #endif Sys_Exit( 0 ); } } #ifdef USE_CURSES for (i = 1; i < argc; i++) { if( !strcmp( argv[i], "+nocurses" ) ) { nocurses = qtrue; break; } } #endif }
/* ================= 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 }
/* ================= Sys_ParseArgs ================= */ void Sys_ParseArgs(int argc, char **argv) { #ifdef FEATURE_CURSES int i; #endif if (argc == 2) { if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) { #ifdef DEDICATED fprintf(stdout, Q3_VERSION " " CPUSTRING " dedicated server (%s)\n", __DATE__); #else fprintf(stdout, "Client: " ET_VERSION "\n"); fprintf(stdout, "Masked as: " FAKE_VERSION "\n"); #endif Sys_Exit(0); } } #ifdef FEATURE_CURSES for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "+nocurses") || !strcmp(argv[i], "--nocurses")) { nocurses = qtrue; break; } } #endif }
void Sys_Error( const char *error, ...) { va_list argptr; char string[1024]; // change stdin to non blocking // NOTE TTimo not sure how well that goes with tty console mode // int on = 0; // setsockopt(0, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int)); //jens fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY); // don't bother do a show on this one heh if (ttycon_on) { tty_Hide(); } 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. }
/* ============= Sys_Error A raw string should NEVER be passed as fmt, because of "%f" type crashers. ============= */ __cdecl void QDECL Sys_Error( const char *fmt, ... ) { FILE * fdout; char* fileout = "sys_error.txt"; va_list argptr; char msg[MAXPRINTMSG]; char buffer[MAXPRINTMSG]; va_start (argptr,fmt); Q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); Com_sprintf(buffer, sizeof(buffer), "\nSys_Error: %s\n", msg); //Print the error to our console Sys_Print( buffer ); //Try to write the error into a file fdout=fopen(fileout, "w"); if(fdout){ fwrite(buffer, strlen(buffer), 1 ,fdout); fclose(fdout); } Sys_WaitForErrorConfirmation( msg ); Sys_Exit( 1 ); // bk010104 - use single exit point. }
void Handle_Home(int disable_screenshot) { if (CFG.home == CFG_HOME_EXIT) { Con_Clear(); printf("\n"); printf_("Exiting..."); __console_flush(0); Sys_Exit(); } else if (CFG.home == CFG_HOME_SCRSHOT) { __console_flush(0); Make_ScreenShot(); if (disable_screenshot) CFG.home = CFG_HOME_EXIT; } else if (CFG.home == CFG_HOME_HBC) { Con_Clear(); printf("\n"); printf_("HBC..."); __console_flush(0); Sys_HBC(); } else if (CFG.home == CFG_HOME_REBOOT) { Con_Clear(); Restart(); } else { // Priiloader magic words, and channels if ((CFG.home & 0xFF) < 'a') { // upper case final letter implies channel Con_Clear(); Sys_Channel(CFG.home); } else { // lower case final letter implies magic word Con_Clear(); *(vu32*)0x8132FFFB = CFG.home; Restart(); } } }
/* ================= Sys_Quit ================= */ void Sys_Quit(void) { Sys_Exit(0); #ifdef USE_WINDOWS_CONSOLE Sys_DestroyConsole(); #endif }
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); }
void Sys_Quit (void) { IN_Shutdown(); Com_ShutdownZoneMemory(); Com_ShutdownHunkMemory(); Sys_Exit(0); }
void Sys_ParseArgs(int argc, char* argv[]) { if ( argc==2 ) { if ( (!strcmp( argv[1], "--version" )) || ( !strcmp( argv[1], "-v" )) ) { Sys_PrintBinVersion( argv[0] ); Sys_Exit(0); } } }
/* ================ Sys_Quit ================ */ void Sys_Quit (qbool restart) { if (restart) { int maxfd = getdtablesize() - 1; // close all file descriptors besides stdin stdout and stderr, I am not sure, perhaps I can safely close even those descriptors too. for (; maxfd > 2; maxfd--) close(maxfd); if (execv(com_argv[0], com_argv) == -1) { Sys_Printf("Restart failed: %s\n", strerror(qerrno)); Sys_Exit(1); } } Sys_Exit(0); // appkit isn't running }
/* ================= Sys_Quit ================= */ void Sys_Quit(void) { NET_Shutdown(); Sys_Exit(0); #if defined (USE_WINDOWS_CONSOLE) Sys_DestroyConsole(); #endif }
static void signal_handler(int sig) // bk010104 - replace this... (NOTE TTimo huh?) { if (signalcaught) { printf("DOUBLE SIGNAL FAULT: Received signal %d, exiting...\n", sig); Sys_Exit(1); // bk010104 - abstraction } signalcaught = qtrue; printf("Received signal %d, exiting...\n", sig); #ifndef DEDICATED //GLimp_Shutdown(); // bk010104 - shouldn't this be CL_Shutdown // rcg08312005 Agreed: changed to CL_Shutdown... --ryan. CL_Shutdown(); #endif SV_Shutdown("Signal caught"); Sys_Exit(0); // bk010104 - abstraction NOTE TTimo send a 0 to avoid DOUBLE SIGNAL FAULT }
/* ================ Sys_Error ================ */ void Sys_Error (const char *error, ...) { static qbool inerror = false; va_list argptr; char text[1024]; sv_error = true; if (inerror) Sys_Exit (1); inerror = true; va_start (argptr, error); vsnprintf (text, sizeof (text), error, argptr); va_end (argptr); #ifdef _CONSOLE if (!((int)sys_nostdout.value || isdaemon)) printf ("ERROR: %s\n", text); #else if (!(COM_CheckParm ("-noerrormsgbox") || isdaemon)) MessageBox (NULL, text, "Error", 0 /* MB_OK */ ); else Sys_Printf ("ERROR: %s\n", text); #endif if (logs[ERROR_LOG].sv_logfile) { SV_Write_Log (ERROR_LOG, 1, va ("ERROR: %s\n", text)); // fclose (logs[ERROR_LOG].sv_logfile); } // FIXME: hack - checking SV_Shutdown with svs.socketip set in -1 NET_Shutdown if (svs.socketip != -1) SV_Shutdown (va("ERROR: %s\n", text)); if ((int)sys_restart_on_error.value) Sys_Quit (true); Sys_Exit (1); }
/* ================= Sys_Quit ================= */ void Sys_Quit(void) { #ifdef __AROS__ NET_Shutdown(); #endif Sys_Exit(0); #if defined (_WIN32) Sys_DestroyConsole(); #endif }
static void signal_handler( int sig, siginfo_t* info, void* secret ) { // bk010104 - replace this... (NOTE TTimo huh?) void* trace[ 64 ]; char** messages = ( char** )NULL; int i, trace_size = 0; #if id386 /* Do something useful with siginfo_t */ ucontext_t* uc = ( ucontext_t* )secret; if ( sig == SIGSEGV ) { printf( "Received signal %d, faulty address is %p, " "from %p\n", sig, info->si_addr, uc->uc_mcontext.gregs[ REG_EIP ] ); } else #endif printf( "Received signal %d, exiting...\n", sig ); trace_size = backtrace( trace, 64 ); #if id386 /* overwrite sigaction with caller's address */ trace[ 1 ] = ( void* )uc->uc_mcontext.gregs[ REG_EIP ]; #endif messages = backtrace_symbols( trace, trace_size ); /* skip first stack frame (points here) */ printf( "[bt] Execution path:\n" ); for ( i = 1; i < trace_size; ++i ) printf( "[bt] %s\n", messages[ i ] ); if ( signalcaught ) { printf( "DOUBLE SIGNAL FAULT: Received signal %d, exiting...\n", sig ); Sys_Exit( 1 ); // bk010104 - abstraction } signalcaught = true; CL_ShutdownOnSignal(); if ( !( GGameType & GAME_Tech3 ) ) { fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) & ~FNDELAY ); } Sys_Exit( 0 ); // bk010104 - abstraction NOTE TTimo send a 0 to avoid DOUBLE SIGNAL FAULT }
/* ================= Sys_SigHandler ================= */ void Sys_SigHandler( int signal ) { static qboolean signalcaught = qfalse; if( signalcaught ) { VM_Forced_Unload_Start(); Com_Printf("DOUBLE SIGNAL FAULT: Received signal %d: \"%s\", exiting...\n", signal, SignalToString(signal)); exit(1); } else { signalcaught = qtrue; #ifndef DEDICATED CL_Shutdown( ); #endif SV_Shutdown( va( "Received signal %d", signal ) ); VM_Forced_Unload_Done(); } if( signal == SIGTERM || signal == SIGINT ) { Sys_Exit( 1 ); } else { Sys_Exit( 2 ); } }
/* ================= 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); Sys_ErrorDialog( string ); Sys_Exit( 3 ); }
void Sys_ParseArgs(int argc, char **argv) { if(argc == 2){ if(!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")){ const char *date = __DATE__; printf(Q3_VERSION " (%s)\n", date); fflush(stdout); Sys_Exit(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. }