OFFTOPIC: write atomicity

Dean Gaudet (dgaudet-list-linux-kernel@arctic.org)
Tue, 28 Apr 1998 22:32:32 -0700 (PDT)


This topic came up recently while I was playing with porting Apache to
NSPR (netscape's portable runtime): "What guarantees are there on the
atomicity of writes?"

Single Unix has a satisfying answer for pipes, FIFOs, and STREAMS. But it
doesn't really give an answer for regular files, or for network sockets.

I know from experience, that for plain files there is an atomicity
guarantee on every unix out there... otherwise Apache's log files, for
example, would be completely broken because there are several processes
writing them all the time, and in the past four years nobody has
complained of jumbled log messages. But Single Unix doesn't mention this,
or give a lower bound for the atomicity.

I generally use the heuristic that if it's <= PIPE_BUF bytes in size I'm
probably safe everywhere... but I wouldn't mind having a standard to point
at.

Two questions:

Is there a standard which guarantees this for files and sockets?

What are linux's guarantees?

Dean

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu