engine: implemented handling SIGTERM signal for proper stopping dedicated server
This commit is contained in:
parent
35ae9f4a64
commit
50c805826f
3 changed files with 27 additions and 0 deletions
|
@ -1072,6 +1072,9 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
|
|||
Host_RunTests( 0 );
|
||||
#endif
|
||||
|
||||
#if XASH_DEDICATED
|
||||
Platform_SetupSigtermHandling();
|
||||
#endif
|
||||
Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED );
|
||||
FS_Init( basedir );
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ void IOS_LaunchDialog( void );
|
|||
|
||||
#if XASH_POSIX
|
||||
void Posix_Daemonize( void );
|
||||
void Posix_SetupSigtermHandling( void );
|
||||
#endif
|
||||
|
||||
#if XASH_SDL
|
||||
|
@ -156,6 +157,13 @@ static inline qboolean Sys_DebuggerPresent( void )
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline void Platform_SetupSigtermHandling( void )
|
||||
{
|
||||
#if XASH_POSIX
|
||||
Posix_SetupSigtermHandling( );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ GNU General Public License for more details.
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "platform/platform.h"
|
||||
#include "menu_int.h"
|
||||
|
||||
|
@ -145,6 +146,21 @@ void Posix_Daemonize( void )
|
|||
|
||||
}
|
||||
|
||||
static void Posix_SigtermCallback( int signal )
|
||||
{
|
||||
Sys_Quit();
|
||||
}
|
||||
|
||||
void Posix_SetupSigtermHandling( void )
|
||||
{
|
||||
#if !XASH_PSVITA
|
||||
struct sigaction act = { 0 };
|
||||
act.sa_handler = Posix_SigtermCallback;
|
||||
act.sa_flags = 0;
|
||||
sigaction( SIGTERM, &act, NULL );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if XASH_TIMER == TIMER_POSIX
|
||||
double Platform_DoubleTime( void )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue