Voting

Please answer this simple SPAM challenge: one plus four?
(Example: nine)

The Note You're Voting On

michael-nospam at sal dot mik dot hyperlink dot net dot au
17 years ago
Note, that on Unix, a rename is a beautiful way of getting atomic updates to files.

Just copy the old contents (if necessary), and write the new contents into a new file, then rename over the original file.

Any processes reading from the file will continue to do so, any processes trying to open the file while you're writing to it will get the old file (because you'll be writing to a temp file), and there is no "intermediate" time between there being a file, and there not being a file (or there being half a file).

Oh, and this only works if you have the temp file and the destination file on the same filesystem (eg. partition/hard-disk).

<< Back to user notes page

To Top