On Thu, Oct 11, 2012 at 03:16:28AM +0200, Harald Becker wrote: > Hi Jim ! > > >Normally, in an editor, you do NOT do this. Consider what happens > >if, behind the scenes, somebody did an "rm file". Your hours of > >typing would go into a still-open file, to an anonymous inode, and > >then quietly disappear. > > .... which I call correct behavior! If someone removed the file you are > currently editing this shall have a reason.
Well you'll find you're pretty lonely. In fact, most people find the opposite extreme to be correct: always writing to a temporary file, and renaming the temporary file over top of the original. This ensures atomicity of the save, so that data won't be lost if your process is killed while saving, and so that other processes reading the file will never see a partially-written file. Of course this also has down-sides, such as losing extended attributes and other file properties the application is not aware of, and not being able to preserve ownership. That's why most programs by default do what busybox vi is doing. > >This would not work if you'd held the FD open all that time. > > Holding FD open is the indicator to many systems (especially network > file systems) that someone is working at the file and some kind > of locking shall be done. That is no one else shall modify the files > contents while you are working at it. There is no precedent for this interpretation. Open file descriptions are not locks. Rich _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
