Skip to content

Commit b075db1

Browse files
authored
Merge pull request #596 from vlm/fix-descriptor-leak
Streamline file descriptor handling during spawning
2 parents f12b35b + b2e4d0b commit b075db1

File tree

2 files changed

+368
-193
lines changed

2 files changed

+368
-193
lines changed

include/llbuild/Basic/PlatformUtility.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ template <typename = FD> struct FileDescriptorTraits;
7272

7373
#if defined(_WIN32)
7474
template <> struct FileDescriptorTraits<HANDLE> {
75+
typedef HANDLE DescriptorType;
7576
static bool IsValid(HANDLE hFile) { return hFile != INVALID_HANDLE_VALUE; }
7677
static void Close(HANDLE hFile) { CloseHandle(hFile); }
7778
static int Read(HANDLE hFile, void *destinationBuffer,
@@ -85,6 +86,8 @@ template <> struct FileDescriptorTraits<HANDLE> {
8586
};
8687
#endif
8788
template <> struct FileDescriptorTraits<int> {
89+
typedef int DescriptorType;
90+
static const int InvalidDescriptor = -1;
8891
static bool IsValid(int fd) { return fd >= 0; }
8992
static void Close(int fd) { close(fd); }
9093
static int Read(int hFile, void *destinationBuffer,

0 commit comments

Comments
 (0)