[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Best way to check file modification time?
From: |
Joost Kremers |
Subject: |
Re: Best way to check file modification time? |
Date: |
19 Nov 2015 14:07:26 GMT |
User-agent: |
slrn/1.0.1 (Linux) |
Stefan Monnier wrote:
>>> I can easily move the mod time checking to a position in the code that's
>>> closer to the actual reading or saving of the file, but I suspect that
>>> only reduces the problem, it doesn't eliminate it altogether. So I'm
>>> wondering if there's a Right Way Ѣ to do this. If not, any advice on how
>>> to reduce the risks as much as possible would be great!
>
> You can't solve this without locking.
Which, if I understand the Elisp manual correctly, can only be done for
files being visited (which I don't do in order to avoid the overhead of
setting up the major mode and any minor modes the user may have
installed), and only works to lock out Emacs.
> The mod-time check has to be done before writing (since writing is
> conditional on the result of the mod-time check), you have a race:
>
> User A checks mod-time
> User B checks mod-time
> User A writes
> User B writes
>
> And this applies no matter how/when the mod-time was originally acquired.
Yes, I figured that. I was just wondering if there were a standard way
of dealing with such cases, since AFAIU it is possible to put a lock on
a file on the OS level. But Emacs doesn't do that, right?
Thanks for the answer, at least I know how to proceed now.
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)