copyFile: atomicity docs/code mismatch
http://haskell.org/ghc/docs/latest/html/libraries/base/System-Directory.html#v%3AcopyFile says:
copyFile old new copies the existing file from old to new. If the new file already exists, it is atomically replaced by the old file. Neither path may refer to an existing directory. The permissions of old are copied to new, if possible.
AFAIK the only way to do atomic replacement is to write to a temporary file, then rename it over the target. However, strace shows that copyFile does open(), ftruncate(), then multiple write()s; this is clearly not atomic.
Conclusion: Either the docs or the code are wrong.
Trac metadata
Trac field | Value |
---|---|
Version | 6.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |