[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed bug on seekable stdin
From: |
Paul Jarc |
Subject: |
Re: sed bug on seekable stdin |
Date: |
Sun, 17 Dec 2006 19:45:31 -0500 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux) |
Eric Blake <address@hidden> wrote:
> I disagree. According to POSIX, "If the most recent operation, other than
> ftell(), on a given stream is fflush(), the file offset in the underlying
> open file description shall be adjusted to reflect the location specified
> by fseek()", with no restriction that the stream must not be an input-only
> stream.
But there is still no specification of what fflush() does on an input
stream. It's undefined by omission. It follows that fflush() +
fseek() can only be used with output files, even though this is not
made explicit on the fseek() page.
> In other words, the only POSIX-sanctioned way to set the offset of
> the underlying fd of a buffered, seekable input stream is to use
> fflush then fseek on that stream.
It's not clear to me that there's any way to do it; this may be a
defect in POSIX. The best I can come up with is fileno() + lseek(),
but then you still have to figure out what offset to jump to.
paul
Re: sed bug on seekable stdin, Paolo Bonzini, 2006/12/18