a couple of random questions (lseek)

Henry Spencer henry at utzoo.uucp
Fri Apr 15 12:19:37 AEST 1988


>      Second, what is the portable way to rewind a Unix file
> descriptor?  On almost every machine I have ever used:
> 
>         lseek(fd, (off_t)0, SEEK_SET);
> 
> works because the offset is a byte count, but it is inevitable
> that on some machine, off_t is the pointer to some kind of
> struct, or at least is *not* simply a byte count...

Not on a *Unix* machine.  There is no portable way to rewind a Unix
file descriptor, because Unix file descriptors are not portable!
On a Unix system, (off_t)0 is fine.  On a seriously non-Unix system,
you have to use stdio streams instead, in which case rewind() is
available.  For vaguely Unix-like systems, all bets are off.
-- 
"Noalias must go.  This is           |  Henry Spencer @ U of Toronto Zoology
non-negotiable."  --DMR              | {allegra,ihnp4,decvax,utai}!utzoo!henry



More information about the Comp.lang.c mailing list