From: Tomas Mraz Date: Thu, 2 May 2019 12:39:01 +0000 (+0200) Subject: Do not fail locking if there is a stale lockfile. X-Git-Tag: 4.7~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F164%2Fhead;p=thirdparty%2Fshadow.git 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. --- 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,