diff options
author | celest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-03-07 11:35:13 +0000 |
---|---|---|
committer | celest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-03-07 11:35:13 +0000 |
commit | 24ec5cc01a034fe378bc0e8dfb7426a2dbbf8563 (patch) | |
tree | b5c5bcfdd52bea7f5b223653e24e757d1369551a /src/common/core.c | |
parent | 4bd24425858e186737a3dd60bbe1ee2f3a4a4e67 (diff) | |
download | hercules-24ec5cc01a034fe378bc0e8dfb7426a2dbbf8563.tar.gz hercules-24ec5cc01a034fe378bc0e8dfb7426a2dbbf8563.tar.bz2 hercules-24ec5cc01a034fe378bc0e8dfb7426a2dbbf8563.tar.xz hercules-24ec5cc01a034fe378bc0e8dfb7426a2dbbf8563.zip |
* 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
Diffstat (limited to 'src/common/core.c')
-rw-r--r-- | src/common/core.c | 31 |
1 files changed, 31 insertions, 0 deletions
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(); |