[PECOFF] Properly close a file descriptor.

This was basically benign resource leak on Unix, but on Windows
it could cause builds to fail because opened file descriptor
prevents other processes from moving or removing the file.

llvm-svn: 222799
This commit is contained in:
Rui Ueyama 2014-11-26 00:21:27 +00:00
parent 659be55daa
commit 65e0ca1bde
1 changed files with 7 additions and 0 deletions

View File

@ -13,6 +13,12 @@
#include "lld/Core/Pass.h"
#include "llvm/ADT/StringRef.h"
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#else
#include <io.h>
#endif
namespace lld {
namespace pecoff {
@ -30,6 +36,7 @@ private:
int fd;
if (llvm::sys::fs::openFileForWrite(path, fd, llvm::sys::fs::F_Append))
llvm::report_fatal_error("failed to create a PDB file");
::close(fd);
}
PECOFFLinkingContext &_ctx;