On 30 November 2016 at 16:16, Giacomo Tesio <giacomo@tesio.it> wrote:
Also I'm looking for "instances that *want* the existing effect", as Charles perfectly described them, something that break without it, so that I can dive deeper into the matter.

cat >x
x: already exists
rm x
cat >x
 # different race
mk x
cp x /tmp/x
x: already exists
rm x
 # this is getting tedious

ed x
1342
$a
hello world
.
w
?exists
!rm x
!
w
1354

basically, most programs or uses that save, copy or update data to a named file are replacing the contents, so "make sure name exists and truncate it"
is the most common case, isn't it? There's no particular reason that couldn't be done by a user-level library call,
create, that ran the three two or three primitive syscalls in sequence. The applications just want the wretched thing there and empty.
(This is separate from some notion of file versioning, which could be done by close, making the create/trunc+update replacement action atomic.)
Mind you, the 3 syscall version adds a more subtle race, which is that the whole path name is re-evaluated 3 times, which opens
up the possibility of a name space change higher up changing the meaning a different way. Still even that is not very likely in practice.