From 64d7688acb2f3d3e9f6152eb5f2cc069393f08bd Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Thu, 2 May 2019 14:39:01 +0200 Subject: [PATCH] Do not fail locking if there is a stale lockfile. As the lockfiles have PID in the name, there can be no conflict in the name with other process, so there is no point in using O_EXCL and it only can fail if there is a stale lockfile from previous execution that crashed for some reason. --- lib/commonio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commonio.c b/lib/commonio.c index 94dda779b..16fa7e755 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -141,7 +141,7 @@ static int do_lock_file (const char *file, const char *lock, bool log) int retval; char buf[32]; - fd = open (file, O_CREAT | O_EXCL | O_WRONLY, 0600); + fd = open (file, O_CREAT | O_TRUNC | O_WRONLY, 0600); if (-1 == fd) { if (log) { (void) fprintf (stderr, -- 2.39.5