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:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=pZjb+zJCN8VSBRrMiH17bLJmNdeohWdMMkLp80R5Nh8 Vp7kVjYuLWGlznMhmhY/N6VWvEsQkK0lvrw9BcRYh0um/aIPrdPVnCY9T+5ddcZz PigfMcji6N2q5NMK2Hu7jmX8DxmbSAQOkwr9s0GsVs3WuXu7FjO0t0fWpbv5Pjyo = 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:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=9rBqWik/Sag6m4ZJAAQ2DOLYlcQ=; b=pddyEr/jnEuoZz4mO RhGPKIZhj7jvS6EgHf4ANwKIenx5ODmucFq1R4IF7Xm/PuJQ6vijfP+y6nmNCrep HNjhLUqBrPFvE5ZrfL/Q0FQGUneq+92al/s5ClV7X9LYzQONW0cyojJnYndHYIbw YithXfCdIauXdIN2K3nVBo4qYg= 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=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: Ishtar.sc.tlinx.org Message-ID: <5877D3CC.4030500@tlinx.org> Date: Thu, 12 Jan 2017 11:06:52 -0800 From: "L. A. Walsh" User-Agent: Thunderbird MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: rename() cannot replace the file which is opened with writable access References: <20170112 DOT 090746 DOT 2056666314950620331 DOT trueroad AT trueroad DOT 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 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