On Wed, Sep 11, 2002 at 05:58:32PM +0300, Oleg Goldshmidt wrote:
> Muli Ben-Yehuda <[EMAIL PROTECTED]> writes:
> 
> > At first we thought that it was a bug with our handling of read() and
> > (lack of) handling of lseek(), but it appears that 'tail /dev/urandom'
> > bechaves in exactly the same way. 
> 
> And /dev/urandom is also unseekable, from a quick look at the
> file_operations in the source... Your suspicion regarding lseek sounds
> reasonable (though I don't know if it is correct) - strace tail shows
> it.

No, that's not it. For !S_ISREG files, tail does the equivalent of:

while (read(...) > 0) {
      allocate a buffer 
      add what we read to the buffer
      continue
}

That loop will only terminate when tail runs out of memory (there's an
xmalloc() inside the loop) or when read returns 0 (EOF) or -1 (error),
and then tail will print everything. 

> Pipes are typically unseekable, AFAIK.

Yup, as is our character device. I'll see if I can find any mentions
of this behaviour from tail in POSIX. 
-- 
Muli Ben-Yehuda
syscalltrack hacker-at-large

Attachment: msg21697/pgp00000.pgp
Description: PGP signature

Reply via email to