http://qs1969.pair.com?node_id=471509


in reply to Re^5: Writing to a file atomically without renaming
in thread Writing to a file atomically without renaming

backup_file has different perms because you copied the file to a new file as a different user. I am not saying backup_file is gone if you hit that case -- only that you end up in a situation where your app or the other apps that use that file are looking at corrupt data (they don't know about backup_file). cat backup_file > file does the following:
trunc file. # this is where you have the race condition. redirects the data in backup_file to file. closes file


-Waswas