tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lseek on tty
Mouse <mouse%Rodents-Montreal.ORG@localhost> wrote:
> > On NetBSD and macOS, lseek(2) on a tty succeeds:
>
> > if (lseek(STDIN_FILENO, 0, SEEK_CUR) == -1 )
>
> > On Linux, this fails.
>
> > I'm trying to think of why seeking on a terminal would make sense.
> > Anybody have an idea?
>
> Quoting from lseek(2) on a handy machine:
>
> Some devices are incapable of seeking. The value of the
> pointer associated with such a device is undefined.
>
> So I'm guessing it depends on whether you think of adding something to
> an undefined value makes sense. To me, it does; the resulting value is
> undefined, but the seek pointer is undefined anyway.
Kinda feel this makes a successful return value of
lseek(2) quite unreliable: it could either mean that
lseek(2) was successful, and has updated the offset,
or it could mean ":shrug: can't seek, you are
wherever you were before calling me".
Wouldn't it be more helpful to the user to have
lseek(2) return -1 here? Since it's undefined, doing
so is equally as valid (as far as the standard is
concerned).
-Jan
Home |
Main Index |
Thread Index |
Old Index