hhvm / hsl-experimental

Experimental features for the Hack Standard Library
MIT License
23 stars 10 forks source link

Make BufferedReader::isEndOfFile() more proactive #150

Closed fredemmott closed 4 years ago

fredemmott commented 4 years ago

The intent is to make code like this safe:

$reader = new IO\BufferedReader(IO\request_input());
while (!$reader->isEndOfFile()) {
  // - Fails with EBADF if STDIN was closed already (e.g. by parent
  //  process/shell)
  // - Fails with EPIPE if it's closed during this read
  $line = await $reader->readLineAsync();
}

I'll also be putting up RFC diffs with additional + modified APIs for this.

Test Plan:

new unit test

facebook-github-bot commented 4 years ago

@fredemmott merged this pull request in hhvm/hsl-experimental@101ea562688b3ff68523c86649d7d659933962ed.