From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125105 invoked by alias); 12 Jan 2017 00:07:54 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 125068 invoked by uid 89); 12 Jan 2017 00:07:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=writable, FAILED, H*x:version, H*UA:version X-HELO: msa03b.plala.or.jp Received: from msa03.plala.or.jp (HELO msa03b.plala.or.jp) (58.93.240.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jan 2017 00:07:52 +0000 Received: from msc02.plala.or.jp ([172.23.12.32]) by msa03b.plala.or.jp with ESMTP id <20170112000748.COFN26487.msa03b.plala.or.jp@msc02.plala.or.jp>; Thu, 12 Jan 2017 09:07:48 +0900 Received: from localhost ([60.47.92.151]) by msc02.plala.or.jp with ESMTP id <20170112000748.MDYA26601.msc02.plala.or.jp@localhost>; Thu, 12 Jan 2017 09:07:48 +0900 Date: Thu, 12 Jan 2017 00:07:00 -0000 Message-Id: <20170112.090746.2056666314950620331.trueroad@trueroad.jp> To: cygwin@cygwin.com Cc: trueroad@trueroad.jp Subject: rename() cannot replace the file which is opened with writable access From: Masamichi Hosoda Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-VirusScan: Outbound; msa03m; Thu, 12 Jan 2017 09:07:48 +0900 X-SW-Source: 2017-01/txt/msg00108.txt.bz2 Hello, I've found that rename() cannot replace the file which is opened with writable access on Cygwin. On Linux, it works. If I understand correctly, it should work under POSIX. Here's sample code for reproduce. ``` #include #include #include #define OLDPATH "oldpath" #define NEWPATH "newpath" int main () { int fd; struct flock fl; char buff[] = "test"; /* create oldpath file */ fd = open (OLDPATH, O_CREAT | O_RDWR | O_TRUNC, 0666); close (fd); /* create newpath file */ fd = open (NEWPATH, O_CREAT | O_RDWR | O_TRUNC, 0666); /* rename *** FAILED on Cygwin *** */ if (rename (OLDPATH, NEWPATH) < 0) perror ("rename"); close (fd); return 0; } ``` Thanks -- 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