tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lseek on tty



> 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.

Also, I'd argue that lseek(,0,SEEK_CUR) makes sense on any descriptor,
since it's not trying to change anything.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index