Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix GH-19570: unable to fseek in /dev/zero and /dev/null #19736

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

Open
nielsdos wants to merge 1 commit into php:PHP-8.3
base: PHP-8.3
Choose a base branch
Loading
from nielsdos:fix-19570

Conversation

Copy link
Member

@nielsdos nielsdos commented Sep 6, 2025

On Linux, these two character devices are exceptions in that they can be seeked. Check their major/minor device number.

On Linux, these two character devices are exceptions in that they can be
seeked. Check their major/minor device number.
@@ -255,7 +259,18 @@ PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC)
static void detect_is_seekable(php_stdio_stream_data *self) {
#if defined(S_ISFIFO) && defined(S_ISCHR)
if (self->fd >= 0 && do_fstat(self, 0) == 0) {
#ifdef __linux__
if (S_ISCHR(self->sb.st_mode)) {
Copy link
Member

@devnexen devnexen Sep 6, 2025

Choose a reason for hiding this comment

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

note that not just linux, allows some character devices being seekable, e.g. freebsd and very likely macos. The equivalent for freebsd at least, can t rely on device versions at all but on a "poorer" solution such as if fseek returns -1 and errno is ESPIPE then it is not seekable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@devnexen devnexen devnexen left review comments

@bukka bukka Awaiting requested review from bukka bukka is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

unable to fseek in /dev/zero and /dev/null

AltStyle によって変換されたページ (->オリジナル) /