On 5/4/21 4:05 PM, Robert Elz wrote:
Date: Tue, 4 May 2021 09:28:04 -0400
From: Chet Ramey <chet.ra...@case.edu>
Message-ID: <c8b1b097-d430-e840-017d-52a1a6a39...@case.edu>
| The issue with the BSDs and terminal devices is that the current code
| only checks for -1/ESPIPE, but they return a different value for errno
| (EINVAL? I forget.)
On traditional unix, since forever, lseek() on a terminal is simply a no-op.
(The seek() sys call that preceded it, on 6th edition and earlier was the
same.) No error, no effect -- or no useful effect, the "file offset" might
get set, so you can't even:
pos = lseek(0,somewhere,0);
if (lseek(0, pos, 0) != somewhere)
/* unseekable */
as that would probably (seem to) succeed, but terminals don't use it.
Yeah, it looks like fstat/S_ISREG is the most portable mechanism.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/