Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!software.org!marshall From: marshall@software.org (Eric Marshall) Newsgroups: comp.unix.wizards Subject: question on lseek behavior Keywords: weirdo Unix system call behavior Message-ID: <1416@software.software.org> Date: 5 Jul 90 12:34:35 GMT Sender: news@software.org Reply-To: marshall@software.org (Eric Marshall) Distribution: usa Organization: Software Productivity Consortium, Herndon, Virginia Lines: 41 I was trying to use lseek to rewind to the beginning of input (a file), but I ran into difficulties. When I run the program below, it outputs the file missing the first 3 characters, as if the lseek didn't do anything, then it outputs the entire file. Could someone please explain why this occurs. I eventually found the rewind(3S) call, and it works fine. I am running on SunOS 4.1. Thanks in advance. seek_test.c: #include #include #include main() { int c; FILE *infile = fopen( "seek_test.c", "r" ); c = getc( infile ); c = getc( infile ); c = getc( infile ); lseek( fileno( infile ), 0L, L_SET ); while ( ( c = getc( infile ) ) != EOF ) putchar( c ); } Eric Marshall Software Productivity Consortium SPC Building 2214 Rock Hill Road Herndon, VA 22070 (703) 742-7153 UUCP: ...!uunet!software!marshall ARPANET: marshall%software.org@relay.cs.net