auto-disable seekable flag
| From: | Michael Spector | Date: | Thu, 08 Sep 2005 11:00:46 +0000 |
| Subject: | auto-disable seekable flag | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-18707@lists.php.net to get a copy of this message | ||
Hi,
I've encountered change in following code behaviour (somewhere between 5.1.0b3 and 5.1.0-HEAD):
posix_isatty (STDOUT);
Now it produces this warning: cannot seek on a pipe
The attached patch adds PHP_STREAM_FLAG_NO_SEEK to the stream flags, if it detects whether
the file descriptor is not seekable.
Thanks.
--
Best regards,
Michael
--- main/streams/plain_wrapper.c.orig 2005-09-08 13:43:52.000000000 +0300 +++ main/streams/plain_wrapper.c 2005-09-08 13:46:39.000000000 +0300 @@ -209,12 +209,15 @@ stream->flags |= PHP_STREAM_FLAG_NO_SEEK; } else { stream->position = lseek(self->fd, 0, SEEK_CUR); + if (stream->position == (off_t)-1) { #ifdef ESPIPE - if (stream->position == (off_t)-1 && errno == ESPIPE) { - stream->position = 0; - self->is_pipe = 1; - } + if (errno == ESPIPE) { + stream->position = 0; + self->is_pipe = 1; + } #endif + stream->flags |= PHP_STREAM_FLAG_NO_SEEK; + } } }
--- main/streams/plain_wrapper.c.orig 2005-09-08 13:43:52.000000000 +0300 +++ main/streams/plain_wrapper.c 2005-09-08 13:46:39.000000000 +0300 @@ -209,12 +209,15 @@ stream->flags |= PHP_STREAM_FLAG_NO_SEEK; } else { stream->position = lseek(self->fd, 0, SEEK_CUR); + if (stream->position == (off_t)-1) { #ifdef ESPIPE - if (stream->position == (off_t)-1 && errno == ESPIPE) { - stream->position = 0; - self->is_pipe = 1; - } + if (errno == ESPIPE) { + stream->position = 0; + self->is_pipe = 1; + } #endif + stream->flags |= PHP_STREAM_FLAG_NO_SEEK; + } } }