52913Re: Race condition during file saving
- Jan 4, 2009
>> If you're writing to a file that another program critically needsHe didn't mean it's your problem personally and that no other user would
>> /that's/ your problem.
> Configuration file, for example, is critically for almost every daemon.
> Do you think that it is only my problem? No, it is very real scenario
> which could happen to everyone who use vim.
experience it. He meant it's your problem as the user, not the editor's
If you edit your config files, most likely you need to SIGHUP the daemon
to reread it anyway. And if you don't, most likely the daemon is aware
of the somewhat dumb practice of reading its config files at
unpredictable intervals, and provides a device, such as crontab -e, to
avoid problems, as has already been mentioned. Playing games moving
temporary files around for the purpose of keeping daemons happy is not
an editor's job, but the user's, or a utility such as crontab's.
Having the editor write to a temporary file and move it into place has
other worse effects as have already been mentioned (breaking of links,
use of file descriptors by calling processes such as crontab -e, etc.).
Indeed, other software sometimes expects the editor to overwrite the
original file, which implies a time with an empty or partially written
So although the current behaviour isn't really ideal, neither are the
alternatives, and in fact, the alternatives are probably worse.
It could be another option, I suppose, or incorporated into an existing
one (it is only possible if writebackup and backup are unset or
copybackup is yes, or there is a time of nonexistence of the file, which
is just as bad), but is it worth the bother? How often are people
actually bitten by this? Very rarely, I think, and the consequences are
far from catastrophic when it happens. It couldn't be the default due to
the other negative side effects of the method, too, so would have to be
set when appropriate, which means you might as well use some other tool
to do the job.
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
- << Previous post in topic