This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

lseek() returning Invalid Argument


I'm getting an Invalid argument error from lseek(), but I can eliminate the error by preceding the lseek() statement with a particular printf() statement.

Configuration:
cygwin1.dll v1005.25.0.0
gcc v3.4.4
Windows XP SP3

Below is a short test program that illustrates the problem. As presented, the 2nd perror() statement is executed and prints the Invalid argument message (errno is 0). Removing the // from the printf() statement will cause the error to magically disappear.

I've tried substituting variations of printf() and sprintf() statements, as well as replacing the statement with a sleep(1) call, but at this point the only way to avoid the error is with the printf() statement shown.

Anyone got an idea of what is going on here?

Thanks.

/* begin test.c */

#include <fcntl.h>
#include <stdio.h>

static int mmfile ;

main(argc,argv)
int argc;
char *argv[];
{

	if ((mmfile = open("test.img", O_RDWR | O_CREAT, 0666)) == -1)
	{
		perror("open() error - ") ;
		exit(1) ;
	}

// printf("mmfile=%d, length=%ld, where_at=%d\n", mmfile, 0x10000L, SEEK_SET) ;

	if (lseek(mmfile, 0x10000L, SEEK_SET) == -1)
	{
		perror("lseek() error - ") ;
		close(mmfile) ;
		exit(1) ;
	}
	close(mmfile) ;
        printf("ended successfully\n") ;
	exit(0) ;
}
/* end test.c */


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]