Loading ...
Sorry, an error occurred while loading the content.

52902Re: Race condition during file saving

Expand Messages
  • Adam Osuchowski
    Jan 4, 2009
    • 0 Attachment
      Bram Moolenaar wrote:
      > That's all taken care of when 'backupcopy' is "auto". If you want the
      > original file to always exist set 'backupcopy' to "yes". Saving files
      > will be slower then, since Vim needs to both write a copy and write the
      > actual file.

      Not quite. Of course, with 'backupcopy' set to "yes", there are not
      moment when another process find file missing, but still file may be empty
      or not completely written:

      open("testfile", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 3
      write(3, "test test test\n"..., 15) = 15
      fsync(3) = 0
      close(3) = 0

      > Since you are overwriting the file there always is a moment it's empty.

      Unless use of rename() syscall, which replace it atomically (with exact
      to hard link cases).

      I know, that these problems result from flawed POSIX file system syscalls
      behaviour, but IMHO it may be made better than it is done now.

      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 19 messages in this topic