From 24ec5cc01a034fe378bc0e8dfb7426a2dbbf8563 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 7 Mar 2005 11:35:13 +0000 Subject: * Updated core and map-server to jA 1115~1137 * Fixed a typo in Volcano git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1206 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/common/core.c') diff --git a/src/common/core.c b/src/common/core.c index 016ade08d..a30445650 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -76,6 +76,11 @@ sigfunc *compat_signal(int signo, sigfunc *func) static void sig_proc(int sn) { int i; + static int is_called = 0; + + if(is_called++) + return; + switch(sn){ case SIGINT: case SIGTERM: @@ -196,11 +201,37 @@ static void display_title(void) */ int runflag = 1; +char pid_file[256]; + +void pid_delete(void) { + unlink(pid_file); +} + +void pid_create(const char* file) { + FILE *fp; + int len = strlen(file); + strcpy(pid_file,file); + if(len > 4 && pid_file[len - 4] == '.') { + pid_file[len - 4] = 0; + } + strcat(pid_file,".pid"); + fp = fopen(pid_file,"w"); + if(fp) { +#ifdef _WIN32 + fprintf(fp,"%d",GetCurrentProcessId()); +#else + fprintf(fp,"%d",getpid()); +#endif + fclose(fp); + atexit(pid_delete); + } +} int main(int argc,char **argv) { int next; + pid_create(argv[0]); Net_Init(); do_socket(); -- cgit v1.2.3-60-g2f50