summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Filesystem.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lld/ELF/Filesystem.cpp b/lld/ELF/Filesystem.cpp
index 6a97b4a778b..1aa345357c4 100644
--- a/lld/ELF/Filesystem.cpp
+++ b/lld/ELF/Filesystem.cpp
@@ -56,13 +56,12 @@ void elf::unlinkAsync(StringRef Path) {
// Instead we open the file and unlink it on this thread. The unlink is fast
// since the open fd guarantees that it is not removing the last reference.
int FD;
- if (sys::fs::openFileForRead(Path, FD))
- return;
-
+ std::error_code EC = sys::fs::openFileForRead(Path, FD);
sys::fs::remove(Path);
// close and therefore remove TempPath in background.
- std::thread([=] { ::close(FD); }).detach();
+ if (!EC)
+ std::thread([=] { ::close(FD); }).detach();
#endif
}
OpenPOWER on IntegriCloud