delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/09/15/18:45:20

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: gballey <galley AT ace-co DOT com>
Subject: lseek() returning Invalid Argument
Date: Tue, 15 Sep 2009 17:43:00 -0500
Lines: 54
Message-ID: <h8p54p$j1l$1@ger.gmane.org>
Mime-Version: 1.0
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019