StoneAge/gmsv/msignal.c

119 lines
2.6 KiB
C
Raw Normal View History

2018-08-07 15:51:35 +08:00
#include "version.h"
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include "buf.h"
#include "net.h"
#include "char.h"
#include "item.h"
#include "object.h"
#include "configfile.h"
#include "lssproto_serv.h"
#include "saacproto_cli.h"
#include "log.h"
#include "petmail.h"
/*------------------------------------------------------------
* lsprotocol <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ëݩ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD>٣<EFBFBD>
* ¦<EFBFBD>ѣ<EFBFBD>߯Ի<EFBFBD><EFBFBD>
* ئ<EFBFBD><EFBFBD>
------------------------------------------------------------*/
static void endlsprotocol( void )
{
lssproto_CleanupServer();
saacproto_CleanupClient();
}
/*------------------------------------------------------------
* <EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>ئ<EFBFBD><EFBFBD>ئ<EFBFBD>з<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ëĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>ƹ<EFBFBD><EFBFBD>ب<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD>ټ<EFBFBD><EFBFBD>ģ<EFBFBD>
* ¦<EFBFBD>ѣ<EFBFBD>߯Ի<EFBFBD><EFBFBD>
* ئ<EFBFBD><EFBFBD>
------------------------------------------------------------*/
static void allDataDump( void )
{
closeAllLogFile();
#ifndef _SIMPLIFY_ITEMSTRING
storeObjects( getStoredir() );
storePetmail();
#endif
storeCharaData();
}
/*------------------------------------------------------------
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ة<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>׻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD>£<EFBFBD>
* ¦<EFBFBD>ѣ<EFBFBD>߯Ի<EFBFBD><EFBFBD>
* ئ<EFBFBD><EFBFBD>
------------------------------------------------------------*/
void shutdownProgram( void )
{
close( acfd );
close( bindedfd );
endlsprotocol();
endConnect();
memEnd();
}
char *DebugFunctionName = NULL;
int DebugPoint = 0;
void sigshutdown( int number )
{
#if USE_MTIO
{
void MTIO_join(void);
MTIO_join();
}
#endif
print( "\n<EFBFBD><EFBFBD>׼<EFBFBD><EFBFBD>Ϣ: %d\n" , number );
if( number == 0 )print( "\nGMSV<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>\n" );
print( "\n<EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD><EFBFBD>(%d)\n", DebugPoint );
print( "\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (%s)\n", DebugFunctionName );
remove( "gmsvlog.err2");
rename( "gmsvlog.err1", "gmsvlog.err2" );
rename( "gmsvlog.err", "gmsvlog.err1" );
rename( "gmsvlog", "gmsvlog.err" );
allDataDump();
signal( SIGINT , SIG_IGN );
signal( SIGQUIT, SIG_IGN );
signal( SIGKILL, SIG_IGN );
signal( SIGSEGV, SIG_IGN );
signal( SIGPIPE, SIG_IGN );
signal( SIGTERM, SIG_IGN );
shutdownProgram();
exit(number);
}
void signalset( void )
{
// CoolFish: Test Signal 2001/10/26
print("\n<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ȡ<EFBFBD>ź<EFBFBD>..\n");
print("SIGINT:%d\n", SIGINT);
print("SIGQUIT:%d\n", SIGQUIT);
print("SIGKILL:%d\n", SIGKILL);
print("SIGSEGV:%d\n", SIGSEGV);
print("SIGPIPE:%d\n", SIGPIPE);
print("SIGTERM:%d\n", SIGTERM);
signal( SIGINT , sigshutdown );
signal( SIGQUIT, sigshutdown );
signal( SIGKILL, sigshutdown );
signal( SIGSEGV, sigshutdown );
signal( SIGPIPE, SIG_IGN );
signal( SIGTERM, sigshutdown );
}