Did you think about use leases to exclusively lock file during save?
I mean fcntl() with F_SETLEASE. It acquires mandatory lock and doesn't break
hard links, which you afraid of. Processes which try to read file during
saving are blocked on open() until lease is removed, so it doesn't change 
behaviour from other processes' point of view. On the other hand, it is
not possible to obtain write lease on file already opened by another
process, and in such a situation (which IMHO shouldn't happen often with
files which are edited by hand) vim should retry acquiring lease after short
sleep or fallback to current behaviour.

This method was originally developed for use in samba, but it is available 
in Linux kernel since 2002 (or even earlier), so it could be said that it
is standard. Certainly, it is Linux specific feature, but if it is
available, why shouldn't it be used.

Any pros or cons?

Regards.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui