Skip to content

Fix bug when pre-reading /dev/stdin to get type#7049

Merged
mattnibs merged 1 commit into
mainfrom
file-type-reset
Jun 16, 2026
Merged

Fix bug when pre-reading /dev/stdin to get type#7049
mattnibs merged 1 commit into
mainfrom
file-type-reset

Conversation

@mattnibs

Copy link
Copy Markdown
Collaborator

On BSD/macOS, open("/dev/stdin") dups fd 0 rather than re-opening the file, so it shares stdin's file offset. Reset to 0 so a re-open reads from the start instead of resuming where the last read left off.

@mattnibs mattnibs requested a review from a team June 15, 2026 21:58
Comment thread sio/fjsonio/stream.go
Comment on lines -77 to -79
if closer, ok := s.r.(io.Closer); ok {
return closer.Close()
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was pre-emptively closing the fjson io.Reader which was causing error when we tried to seek to the beginning after gathering type info.

@mattnibs mattnibs force-pushed the file-type-reset branch 5 times, most recently from 926dd55 to b86a721 Compare June 15, 2026 22:28
Comment thread sio/anyio/ztests/sup-stdin.yaml Outdated
On BSD/macOS, open("/dev/stdin") dups fd 0 rather than re-opening the
file, so it shares stdin's file offset. Reset to 0 so a re-open reads
from the start instead of resuming where the last read left off.
@mattnibs mattnibs merged commit 5cb6b37 into main Jun 16, 2026
2 checks passed
@mattnibs mattnibs deleted the file-type-reset branch June 16, 2026 20:22
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