diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-03-04 05:26:14 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-03-04 05:26:14 +0000 |
commit | 6a6206d440152b534b3e08e87b0ab3168573c438 (patch) | |
tree | 80059f6a6dfc4248b74b3bad549eb31f16fbc5c1 /clang/lib | |
parent | 8757fc5594583b282f0514a5cf6919f6ceca4395 (diff) | |
download | bcm5719-llvm-6a6206d440152b534b3e08e87b0ab3168573c438.tar.gz bcm5719-llvm-6a6206d440152b534b3e08e87b0ab3168573c438.zip |
[VFS] Switch from close to SafelyCloseFileDescriptor
The SafelyCloseFileDescriptor machinery does the right thing in the face
of signals while close will do something platform specific which results
in the FD potentially getting leaked.
llvm-svn: 262687
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 6977f400287..ba846c84139 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/Errc.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" +#include "llvm/Support/Process.h" #include "llvm/Support/YAMLParser.h" #include "llvm/Config/llvm-config.h" #include <atomic> @@ -158,21 +159,10 @@ RealFile::getBuffer(const Twine &Name, int64_t FileSize, IsVolatile); } -// FIXME: This is terrible, we need this for ::close. -#if !defined(_MSC_VER) && !defined(__MINGW32__) -#include <unistd.h> -#include <sys/uio.h> -#else -#include <io.h> -#ifndef S_ISFIFO -#define S_ISFIFO(x) (0) -#endif -#endif std::error_code RealFile::close() { - if (::close(FD)) - return std::error_code(errno, std::generic_category()); + std::error_code EC = sys::Process::SafelyCloseFileDescriptor(FD); FD = -1; - return std::error_code(); + return EC; } namespace { |