Skip to content

Commit 7b72fbd

Browse files
authored
Merge pull request #2383 from gmittert/DownToTheFilter
[Windows] Handle EOF with Pipes
2 parents fdc818a + 208cfba commit 7b72fbd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Foundation/FileHandle.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,12 @@ open class FileHandle : NSObject {
266266

267267
var BytesRead: DWORD = 0
268268
if !ReadFile(_handle, buffer.advanced(by: total), BytesToRead, &BytesRead, nil) {
269+
let err = GetLastError()
270+
if err == ERROR_BROKEN_PIPE && untilEOF {
271+
break
272+
}
269273
free(buffer)
270-
throw _NSErrorWithWindowsError(GetLastError(), reading: true)
274+
throw _NSErrorWithWindowsError(err, reading: true)
271275
}
272276
total += Int(BytesRead)
273277
if BytesRead == 0 || !untilEOF {

0 commit comments

Comments
 (0)