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 <olce.freedesktop@certner.fr>
This commit is contained in:
Olivier Certner 2021-02-09 10:49:00 +01:00 committed by Povilas Kanapickas
parent d66b7ec129
commit d4b38e1119
1 changed files with 7 additions and 1 deletions

View File

@ -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)