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:date:message-id:to:cc:subject:from :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=xV/UTeFqBZmKFEiBzCPs5payqU+e68Md6GNyb5lyhX52fhTYJCmZa axdYmmbFDsgjszqd7IjJheTFMpYvXJebsn5gHpIr21Gsw1ut49mwMFCEDiEd1xEr 5jKCPEjb8/2/wf7DkkcI/xf5BBciTGs5i2dZKOohwcRm8d9XEnu+lI= 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:date:message-id:to:cc:subject:from :mime-version:content-type:content-transfer-encoding; s=default; bh=xJ0iGvrPUhhF1xydQ7WVpn+paB8=; b=Zu3bRn87HXp2JaP18Z2rJVO5ZAjK In6yTMddKZ5JFrkoxAlIVLqhqzycTVtlvdDrs+eJEbYMAwQDxfTQzBIwAF+XsYXS /rWnVeUN6AeRksUOwbgxIuCOT/r9hhSQRC7Exg51uNv3g2pxmh20xCE7qJbZaTAi 3hDMfw3jX0FB8hQ= 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.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 Date: Thu, 12 Jan 2017 09:07:46 +0900 (JST) Message-Id: <20170112.090746.2056666314950620331.trueroad@trueroad.jp> To: cygwin AT cygwin DOT com Cc: trueroad AT trueroad DOT 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 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