From 37575693186976cf7828832e48b4b75edc469cd1 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 21 Mar 2014 01:25:37 +0000 Subject: [Support] Make sure sys::fs::remove can remove symbolic links and make sure LockFileManager can handle a symbolic link that points nowhere. llvm-svn: 204422 --- llvm/lib/Support/LockFileManager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Support/LockFileManager.cpp') diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index ba1047b88ac..c8472d88055 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -29,16 +29,13 @@ using namespace llvm; /// \returns The process ID of the process that owns this lock file Optional > LockFileManager::readLockFile(StringRef LockFileName) { - // Check whether the lock file exists. If not, clearly there's nothing - // to read, so we just return. - if (!sys::fs::exists(LockFileName)) - return None; - // Read the owning host and PID out of the lock file. If it appears that the // owning process is dead, the lock file is invalid. std::unique_ptr MB; - if (MemoryBuffer::getFile(LockFileName, MB)) + if (MemoryBuffer::getFile(LockFileName, MB)) { + sys::fs::remove(LockFileName); return None; + } StringRef Hostname; StringRef PIDStr; -- cgit v1.2.3