X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Zlj rJ+Hbv6VQtrCwdYT5eX2o8fMfRUAMfjmj6Hqdq8S5pl4J9QAG35IrvfrjLiod3F+ fsgEUE+cC2NaKSysK57+vJ5mFmggQdaJ6tZ6AF6r26kNV/vgBDww5NVJALhP4cdS iSZK+MNeWWTUCtIN6kFYsChSSkoRm44ZfOA3UPog= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=2i3WFtsXW cxaZp/Fqo/YL0q0SJo=; b=tuhNm7uoUhK/dvJwZJ4ZmvdBRaAjXQb/0JdrUAgOK h6mMow7pgEQomdsOagk7bWCxjCDcviQnF0YknbsJDrt84uJNBGlu7G4IWd8tRjD5 Y60OM3WQyzDp4lDTuChqLrUzllsXiDyHiXRUN4xQM2DNp4a1TqQZ22zWlWc8F+y7 Zk= 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 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: plane.gmane.org To: cygwin AT cygwin DOT com From: Roy Subject: open(O_RDWR) and lseek() fail Date: Fri, 28 Mar 2014 09:29:29 +0800 Lines: 47 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit User-Agent: Opera Mail/11.64 (Win32) X-IsSubscribed: yes Hello list, I wonder why lseek(SEEK_CUR) on open(O_RDWR) fails with errno=22, the code works on Linux: #include #include #include #include int main(int argc, char** argv){ int f,v1,v2; v1 = 1234; close(creat("1.bin", 0600)); f = open("1.bin", O_RDWR); printf("wrote %d bytes.\n",write(f, (char *)&v1, sizeof(int))); printf("pos = %d\n",lseek(f, 0l, SEEK_CUR)); printf("errno = %d\n",errno); printf("seek to beginning.\n"); lseek(f, 0l, SEEK_SET); printf("errno = %d\n",errno); printf("read %d bytes.\n",read(f, (char *)&v2, sizeof(int))); printf("v2 = %d\n",v2); close(f); } On Linux it gives no error: wrote 4 bytes. pos = 4 errno = 0 seek to beginning. errno = 0 read 4 bytes. v2 = 1234 But not on cgywin(both 1.5 and 1.7 fails): wrote 4 bytes. pos = -1 errno = 22 seek to beginning. errno = 22 read 0 bytes. v2 = 2272412 Whats wrong with cygwin? Regards, Roy -- 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