diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/core.c | 7 | ||||
-rw-r--r-- | src/common/lock.c | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/common/core.c b/src/common/core.c index 2546f4e..7267d8f 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -7,6 +7,7 @@ #include <unistd.h> #endif #include <signal.h> +#include <wait.h> #include "core.h" #include "socket.h" @@ -48,6 +49,9 @@ static void sig_proc(int sn) } exit(0); break; + case SIGCHLD: + wait(&i); + break; } } @@ -135,7 +139,8 @@ int main(int argc,char **argv) compat_signal(SIGPIPE,SIG_IGN); compat_signal(SIGTERM,sig_proc); compat_signal(SIGINT,sig_proc); - + compat_signal(SIGCHLD,sig_proc); + // Signal to create coredumps by system when necessary (crash) compat_signal(SIGSEGV, SIG_DFL); #ifndef LCCWIN32 diff --git a/src/common/lock.c b/src/common/lock.c index 67001f9..c584017 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -1,4 +1,5 @@ +#include <unistd.h> #include <stdio.h> #include "lock.h" #include "socket.h" @@ -10,12 +11,12 @@ FILE* lock_fopen(const char* filename,int *info) { char newfile[512]; FILE *fp; - int no = 0; + int no = getpid(); // 安全なファイル名を得る(手抜き) do { sprintf(newfile,"%s_%04d.tmp",filename,++no); - } while((fp = fopen_(newfile,"r")) && (fclose_(fp), no<9999) ); + } while((fp = fopen_(newfile,"r")) && (fclose_(fp), no<99999) ); *info = no; return fopen_(newfile,"w"); } |