Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!cca!mirror!ima!haddock!karl From: karl@haddock.UUCP (Karl Heuer) Newsgroups: comp.unix.wizards Subject: Re: Seek on a pipe Message-ID: <633@haddock.UUCP> Date: Fri, 26-Jun-87 16:23:39 EDT Article-I.D.: haddock.633 Posted: Fri Jun 26 16:23:39 1987 Date-Received: Sat, 27-Jun-87 11:07:39 EDT References: <7359@brl-adm.ARPA> <983@bobkat.UUCP> <5872@brl-smoke.ARPA> <791@mcgill-vision.UUCP> <7074@mimsy.UUCP> Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer) Organization: Interactive Systems, Boston Lines: 16 Summary: Seek on a character-special file In article <7074@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <791@mcgill-vision.UUCP> mouse@mcgill-vision.UUCP (der Mouse) writes: >>A program that expects to do seeks should ensure that the object can seek > >... which is exactly why I wrote a routine to do this. > return (lseek(fd, 0L, 1) >= 0 && !isatty(fd)); "isatty" is not sufficient; character-special files in general are incapable of seeking. I ran into this same question a couple of years ago, reluctantly decided that I had to use fstat(), and wrote it that way in my library. (I called it "canseek".) I wish lseek would just fail, instead of being a no-op, on nonseekable files other than pipes. Does anyone know what POSIX says about the matter? Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint