Skip to content

Conversation

@bxwllzz
Copy link
Contributor

@bxwllzz bxwllzz commented Dec 27, 2025

  • read(): POSIX specifies that errno is undefined when read() return values are >= 0. The previous retry logic had bugs: When read() returns 0 (EOF), the loop condition checked errno before the return value. Since errno might be stale from a previous call, this could trigger a false retry on EOF.

  • readdir(): When readdir() reaches the end of directory, it returns NULL without modifying errno. Setting errno=0 before the loop caused an infinite loop.

#146

- read(): POSIX specifies that errno is undefined when read() return values are >= 0.
  The previous retry logic had bugs:
  When read() returns 0 (EOF), the loop condition checked errno before
  the return value. Since errno might be stale from a previous call, this could
  trigger a false retry on EOF.

- readdir(): When readdir() reaches the end of directory, it returns NULL
  without modifying errno. Setting errno=0 before the loop caused an infinite loop.
@gulrak
Copy link
Owner

gulrak commented Dec 28, 2025

Good find! Thank you for the fix!

@gulrak gulrak merged commit 1b0c27e into gulrak:master Dec 28, 2025
9 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants