Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tomerd opened this issue May 28, 2021 · 1 comment

Comments

@tomerd
Copy link
Member

tomerd commented May 28, 2021

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")
  }
}
@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants