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 Subject: lseek() returning Invalid Argument Date: Tue, 15 Sep 2009 17:43:00 -0500 Lines: 54 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: List-Subscribe: List-Archive: List-Post: List-Help: , 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 #include 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