mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-29 23:15:56 -04:00
it's always nice to be signal aware... using SIGTERM and having all processes know how to cleanly exit when it is received benefits us even when not profiling (kill -1 <pid>)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
#include <signal.h>
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
|
||||
@@ -27,10 +28,21 @@
|
||||
#include "LocalizationManager.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
inline void signalHandler(int s){
|
||||
printf("CommoditiesServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "FirstConnectionServer.h"
|
||||
#include "ConfigConnectionServer.h"
|
||||
#include "ConnectionServer.h"
|
||||
@@ -12,6 +14,11 @@
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
inline void signalHandler(int s){
|
||||
printf("ConnectionServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void dumpPid(const char * argv)
|
||||
@@ -25,6 +32,12 @@ void dumpPid(const char * argv)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
@@ -53,10 +66,6 @@ int main(int argc, char ** argv)
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "LogServer.h"
|
||||
|
||||
@@ -17,10 +19,23 @@
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
inline void signalHandler(int s){
|
||||
printf("LogServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
@@ -47,10 +62,6 @@ int main(int argc, char **argv)
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "LoginServer.h"
|
||||
|
||||
@@ -19,21 +16,17 @@
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
inline void signalHandler(int s){
|
||||
printf("LoginServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#ifdef ENABLE_PROFILING
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
#endif
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "FirstPlanetServer.h"
|
||||
#include "ConfigPlanetServer.h"
|
||||
#include "PlanetServer.h"
|
||||
@@ -14,6 +16,11 @@
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "sharedUtility/SetupSharedUtility.h"
|
||||
|
||||
inline void signalHandler(int s){
|
||||
printf("PlanetServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void dumpPid(const char * argv)
|
||||
@@ -27,6 +34,12 @@ void dumpPid(const char * argv)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
// dumpPid(argv[0]);
|
||||
|
||||
SetupSharedThread::install();
|
||||
@@ -66,9 +79,5 @@ int main(int argc, char ** argv)
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ bool ProcessSpawner::isProcessActive(uint32 pid)
|
||||
|
||||
void ProcessSpawner::kill(uint32 pid)
|
||||
{
|
||||
IGNORE_RETURN(::kill(static_cast<int>(pid), SIGKILL));
|
||||
IGNORE_RETURN(::kill(static_cast<int>(pid), SIGTERM));
|
||||
int status;
|
||||
IGNORE_RETURN(waitpid(static_cast<int>(pid), &status, 0));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
#include "ConfigTaskManager.h"
|
||||
@@ -13,10 +15,21 @@
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
inline void signalHandler(int s){
|
||||
printf("TaskManager terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
@@ -41,9 +54,5 @@ int main(int argc, char ** argv)
|
||||
TaskManager::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "FirstSwgDatabaseServer.h"
|
||||
|
||||
#include "SwgDatabaseServer/SwgDatabaseServer.h"
|
||||
@@ -19,6 +21,11 @@
|
||||
#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h"
|
||||
#include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h"
|
||||
|
||||
inline void signalHandler(int s){
|
||||
printf("SwgDatabaseServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void dumpPid(const char * argv)
|
||||
@@ -32,6 +39,12 @@ void dumpPid(const char * argv)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
// dumpPid(argv[0]);
|
||||
|
||||
SetupSharedThread::install();
|
||||
@@ -72,9 +85,5 @@ int main(int argc, char ** argv)
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "serverGame/GameServer.h"
|
||||
|
||||
@@ -32,10 +34,20 @@
|
||||
#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h"
|
||||
#include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h"
|
||||
|
||||
inline void signalHandler(int s){
|
||||
printf("LoginServer terminating, signal %d\n",s);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = signalHandler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
@@ -136,10 +148,6 @@ int main(int argc, char ** argv)
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove ();
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user