public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* rename() cannot replace the file which is opened with writable access
@ 2017-01-12  0:07 Masamichi Hosoda
  2017-01-12  5:50 ` Andrey Repin
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Masamichi Hosoda @ 2017-01-12  0:07 UTC (permalink / raw)
  To: cygwin; +Cc: trueroad

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 <stdio.h>
#include <fcntl.h>
#include <unistd.h>

#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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-01-14 15:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-12  0:07 rename() cannot replace the file which is opened with writable access Masamichi Hosoda
2017-01-12  5:50 ` Andrey Repin
2017-01-12 14:41   ` Masamichi Hosoda
2017-01-12 15:30     ` Nellis, Kenneth (Conduent)
2017-01-12 15:36       ` Corinna Vinschen
2017-01-12 16:38         ` cyg Simple
2017-01-12 19:06 ` L. A. Walsh
2017-01-12 21:49 ` Corinna Vinschen
2017-01-14  4:00   ` Masamichi Hosoda
2017-01-14 15:38     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).