diff options
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/LockFileManager.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 4 |
2 files changed, 5 insertions, 8 deletions
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<std::pair<std::string, int> > 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<MemoryBuffer> MB; - if (MemoryBuffer::getFile(LockFileName, MB)) + if (MemoryBuffer::getFile(LockFileName, MB)) { + sys::fs::remove(LockFileName); return None; + } StringRef Hostname; StringRef PIDStr; diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 500b7fecb74..1c910536106 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -305,7 +305,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) { StringRef p = path.toNullTerminatedStringRef(path_storage); struct stat buf; - if (stat(p.begin(), &buf) != 0) { + if (lstat(p.begin(), &buf) != 0) { if (errno != errc::no_such_file_or_directory || !IgnoreNonExisting) return error_code(errno, system_category()); return error_code::success(); @@ -316,7 +316,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) { // check ensures that what we're trying to erase is a regular file. It // effectively prevents LLVM from erasing things like /dev/null, any block // special file, or other things that aren't "regular" files. - if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) + if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode) && !S_ISLNK(buf.st_mode)) return make_error_code(errc::operation_not_permitted); if (::remove(p.begin()) == -1) { |

