Skip to content

Commit 2d72fdb

Browse files
committed
File: Handle Windows ERROR_BROKEN_PIPE for synchronous reads
1 parent b973256 commit 2d72fdb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Libraries/File/File.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,13 @@ SC::Result SC::FileDescriptor::read(Span<char> data, Span<char>& actuallyRead, u
159159

160160
SC::Result SC::FileDescriptor::read(Span<char> data, Span<char>& actuallyRead)
161161
{
162-
DWORD numberOfReadBytes;
162+
DWORD numberOfReadBytes = 0;
163163
const BOOL res =
164164
::ReadFile(handle, data.data(), static_cast<DWORD>(data.sizeInBytes()), &numberOfReadBytes, nullptr);
165-
SC_TRY_MSG(res, "ReadFile failed");
165+
if (res == FALSE and ::GetLastError() != ERROR_BROKEN_PIPE)
166+
{
167+
return Result::Error("ReadFile failed");
168+
}
166169
return Result(data.sliceStartLength(0, static_cast<size_t>(numberOfReadBytes), actuallyRead));
167170
}
168171

0 commit comments

Comments
 (0)