diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 098458f7eb..a77a326506 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -592,9 +592,8 @@ virPidFileForceCleanupPath(const char *path) if (virPidFileReadPath(path, &pid) < 0) return -1; - if (virPidFileAcquirePath(path, false, 0) == 0) { - virPidFileReleasePath(path, fd); - } else { + fd = virPidFileAcquirePath(path, false, 0); + if (fd < 0) { virResetLastError(); /* Only kill the process if the pid is valid one. 0 means @@ -607,5 +606,8 @@ virPidFileForceCleanupPath(const char *path) return -1; } + if (fd) + virPidFileReleasePath(path, fd); + return 0; }