forked from OSchip/llvm-project
[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:
parent
659be55daa
commit
65e0ca1bde
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue