Revert "[lld] Fix elf::unlinkAsync detached thread"
This reverts commit 2694810153cf992823eb45253d26b8567424438f.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@354080 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/ELF/Filesystem.cpp b/ELF/Filesystem.cpp
index 5c8475f..957534a 100644
--- a/ELF/Filesystem.cpp
+++ b/ELF/Filesystem.cpp
@@ -58,26 +58,9 @@
std::error_code EC = sys::fs::openFileForRead(Path, FD);
sys::fs::remove(Path);
- if (EC)
- return;
-
// close and therefore remove TempPath in background.
- std::mutex M;
- std::condition_variable CV;
- bool Started = false;
- std::thread([&, FD] {
- {
- std::lock_guard<std::mutex> L(M);
- Started = true;
- CV.notify_all();
- }
- ::close(FD);
- }).detach();
-
- // GLIBC 2.26 and earlier have race condition that crashes an entire process
- // if the main thread calls exit(2) while other thread is starting up.
- std::unique_lock<std::mutex> L(M);
- CV.wait(L, [&] { return Started; });
+ if (!EC)
+ std::thread([=] { ::close(FD); }).detach();
#endif
}