From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107351 invoked by alias); 12 Jan 2017 19:06:59 -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 107341 invoked by uid 89); 12 Jan 2017 19:06:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: Ishtar.sc.tlinx.org Received: from ishtar.tlinx.org (HELO Ishtar.sc.tlinx.org) (173.164.175.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jan 2017 19:06:55 +0000 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id v0CJ6pWi050175 for ; Thu, 12 Jan 2017 11:06:54 -0800 Message-ID: <5877D3CC.4030500@tlinx.org> Date: Thu, 12 Jan 2017 19:06:00 -0000 From: "L. A. Walsh" User-Agent: Thunderbird MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: rename() cannot replace the file which is opened with writable access References: <20170112.090746.2056666314950620331.trueroad@trueroad.jp> In-Reply-To: <20170112.090746.2056666314950620331.trueroad@trueroad.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00130.txt.bz2 Masamichi Hosoda wrote: > 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. --- > #define OLDPATH "oldpath" > #define NEWPATH "newpath" > > int main () { > int fd; > struct flock fl; > char buff[] = "test"; > fd = open (OLDPATH, O_CREAT | O_RDWR | O_TRUNC, 0666); > close (fd); > fd = open (NEWPATH, O_CREAT | O_RDWR | O_TRUNC, 0666); > if (rename (OLDPATH, NEWPATH) < 0) perror ("rename"); > ---- What are you trying to do by renaming the oldfile over the top of a still-open-for-write, "newfile". Why rename over the top of another file? What are you trying to do? Maybe there is a better way to do it? ;-). -- 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