lseek returning 2**32-1 on error instead of -1

Yitzchak Scott-Thoennes sthoenna@efn.org
Wed Apr 21 00:24:00 GMT 2004


Using the latest snapshot 20040420 (though I think it may have been
this way since at least 1.5.2):

$ cat lseeker.c
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

int main(int argc, char **argv) {
   off_t offset = -1, result;

   printf ("offsets are size %d.\n", sizeof (off_t));
   printf ("offsets are %s.\n", ( offset < 0 ? "signed" : "unsigned" ));
   printf ("seeking to offset %lld.\n", offset);

   errno = 0;
   result = lseek (fileno (stdin), offset, SEEK_CUR);
   printf ("got %lld (%s).\n", result, strerror (errno));
   return 0;
}

$ gcc -Wall lseeker.c; ./a.exe<lseeker.c
offsets are size 8.
offsets are signed.
seeking to offset -1.
got 4294967295 (Invalid argument).

I believe this to be the cause of perl's op/sysio.t test 39 failing.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list