aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/tar.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/archival/tar.c b/archival/tar.c
index c39d5787f..23af9ffa3 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -472,7 +472,8 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
tbInfo.tarFd = fileno(stdout);
tbInfo.verboseFlag = verboseFlag ? 2 : 0;
} else {
- tbInfo.tarFd = open(tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ unlink(tarName);
+ tbInfo.tarFd = open(tarName, O_WRONLY | O_CREAT | O_EXCL, 0644);
tbInfo.verboseFlag = verboseFlag ? 1 : 0;
}