Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello monk masters, For the sake of exception safety, I want to write to a file atomically. In the process of writing to a file exceptions could be thrown if for example there is no more disk space. I know of the module IO::AtomicFile, which, it would seem, should make me happy. However, this module uses the old trick of writing to a temporary file and then renaming it. This is nice for atomicity, but causes one problem: it clobbers the file attributes like owner and permissions. For example, I have this file: -rw--w---- 1 user1 group1 ... filename Let's assume I am running my program as "user2", which is a member of "group1". If I write to a temporary file and then move it, the owner of the file will have changed to "user2". Only root can change the owner of a file, so I'm stuck. Is there a way to write to a file atomically without using rename()? Thanks! In reply to Writing to a file atomically without renaming by nomis80
|
|