From d4b38e111946b934d0f8438dc295dd9f7316318c Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Tue, 9 Feb 2021 10:49:00 +0100 Subject: [PATCH] os: Properly report failure to link lock file Stop assuming that a failure to link always means that the file indeed exists. In case of other failure (e.g., permissions), the user would get an inconsistent "Can't read lock file" message. Signed-off-by: Olivier Certner --- os/utils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/os/utils.c b/os/utils.c index c3565f971..231554954 100644 --- a/os/utils.c +++ b/os/utils.c @@ -329,7 +329,7 @@ LockServer(void) */ break; } - else { + else if (errno == EEXIST) { /* * Read the pid from the existing file */ @@ -374,6 +374,12 @@ LockServer(void) LockFile, "\tand start again."); } } + else { + unlink(tmp); + FatalError + ("Linking lock file (%s) in place failed: %s\n", + LockFile, strerror(errno)); + } } unlink(tmp); if (!haslock)