Skip to content

Conversation

@ryanbreen
Copy link
Owner

Summary

  • Per POSIX, dup2(fd, fd) should return fd immediately without modifying anything
  • The previous implementation would close_read()/close_write() and then add_reader()/add_writer() in separate operations, temporarily setting the pipe reference count to zero
  • A concurrent write during this window would see readers == 0 and incorrectly return EPIPE
  • Added early return when old_fd == new_fd to avoid this race

Test plan

  • Build completes with zero warnings
  • Verify dup2(fd, fd) returns immediately without affecting pipe state

🤖 Generated with Claude Code

Per POSIX, dup2(fd, fd) should return fd immediately without modifying
anything. The previous implementation would close_read()/close_write()
and then add_reader()/add_writer() in separate operations, temporarily
setting the pipe reference count to zero. A concurrent write during this
window would see readers == 0 and incorrectly return EPIPE.

Added early return when old_fd == new_fd to avoid this race.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@cursor
Copy link

cursor bot commented Dec 15, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on January 12.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@ryanbreen ryanbreen merged commit 092b217 into main Dec 15, 2025
1 check 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