diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-08-09 11:22:27 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-08-09 11:22:27 +0100 |
commit | 89f5a327b82d0f15c2988d918c8f9f57a156da36 (patch) | |
tree | 18f526620ac7a1c0abdabc310219ca8e6f9aabe5 | |
parent | a9e5295d8735ff4ffe10e63f48728380edf6d7a0 (diff) | |
download | nsgenbind-89f5a327b82d0f15c2988d918c8f9f57a156da36.tar.gz nsgenbind-89f5a327b82d0f15c2988d918c8f9f57a156da36.tar.bz2 |
Stop parallel runs of genbind temporary files conflicting.
-rw-r--r-- | src/utils.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c index 1e8ec23..0952744 100644 --- a/src/utils.c +++ b/src/utils.c @@ -11,6 +11,8 @@ #include <stdbool.h> #include <errno.h> #include <stdlib.h> +#include <sys/types.h> +#include <unistd.h> #include "options.h" #include "utils.h" @@ -35,7 +37,7 @@ static char *genb_fpath_tmp(const char *fname) fpathl = strlen(options->outdirname) + strlen(fname) + 3; fpath = malloc(fpathl); - snprintf(fpath, fpathl, "%s/%s~", options->outdirname, fname); + snprintf(fpath, fpathl, "%s/%s.%d", options->outdirname, fname, getpid()); return fpath; } @@ -111,6 +113,7 @@ int genb_fclose_tmp(FILE *filef_tmp, const char *fname) (memcmp(tbuf, fbuf, trd) != 0)) { /* file doesnt match */ fclose(filef_tmp); + fclose(filef); remove(fpath); rename(tpath, fpath); |