]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Do not fail locking if there is a stale lockfile. 164/head
authorTomas Mraz <tmraz@fedoraproject.org>
Thu, 2 May 2019 12:39:01 +0000 (14:39 +0200)
committerTomas Mraz <tmraz@fedoraproject.org>
Thu, 2 May 2019 12:39:01 +0000 (14:39 +0200)
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

index 94dda779b33cde91bcf4900d2237e040b9fa3f66..16fa7e755cd54a7abb0f20aa4296a0e411901e87 100644 (file)
@@ -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,