summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/lock.c5
1 files changed, 3 insertions, 2 deletions
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");
}