Skip to content

[SR-14669] Foundation: Pipe's fileHandleForReading.readabilityHandler called multiple times with zero bytes content #3224

Open
@tomerd

Description

@tomerd
Previous ID SR-14669
Radar rdar://problem/78626941
Original Reporter @tomerd
Type Bug
Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug, Linux, Windows
Assignee None
Priority Medium

md5: 30e74c22b4f95eebac2ef61ab1954b5f

Issue Description:

The following code handles pipe input.

Based on the documentation, when `availableData` length is 0, it means the end of the pipe has been reached and the read operation is complete. Hover, we seen the handler get called with zero length availableData multiple times, which seems like a bug.

let stdoutPipe = Pipe()
stdoutPipe.fileHandleForReading.readabilityHandler = { (fh : FileHandle) -> Void in
  let data = fh.availableData
  if (data.count == 0) {
    print("finished")
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions