How does one programmatically determine if “write” system call is atomic on a particular file?

前端 未结 1 819
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 05:38

In some cases the coder cannot rely on system calls being atomic, e.g. if the file is on a NFS filesystem. (c.f. NFS Overview, FAQ and HOWTO Documents). But atomic system

相关标签:
1条回答
  • 2021-01-19 05:45

    The write call as defined in POSIX has no atomicity guarantee at all. So you don't need to confirm anything, it's not atomic.

    It doesn't even guarantee that the data will have reached the hard drive (if there is a drive at all) if it completes successfully. Successfully reading back the data doesn't give you any guarantees either.

    You'll need to use the sync family of functions to get some durability guarantees.

    0 讨论(0)
提交回复
热议问题