Is a successful call to write(2) atomic?

Paul Procacci pprocacci at gmail.com
Tue Jun 15 23:44:01 UTC 2021


> I frankly don't know.  It seems highly likely to me that Posix is most
> probably very precise in defining the behavior, but one would have to
> wade through a hundred pages or so to find the exact and crisp answer.--
>
>
I read some of them last night before responding to you to ensure all my
ducks were in a row.  ;)

https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_05_01
https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_07
https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html

The last link in particular ... used to read as:

"This volume of POSIX.1-2008 does not specify behavior of concurrent writes
to a file from multiple processes. Applications should use some form of
concurrency control. "

It now reads:

This volume of POSIX.1-2017 does not specify the behavior of concurrent
writes to a regular file from multiple threads, except that each write is
atomic (see *Thread Interactions with Regular File Operations*
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_07>).
Applications should use some form of concurrency control.

In both cases, it states:  "Applications should use some form of
concurrency control".

~Paul

__________________

:(){ :|:& };:


More information about the freebsd-questions mailing list