I'm reading about pipe(7)
s in Linux and came across the following thing:
POSIX.1 says that
write(2)
s of less thanPIPE_BUF
bytes must be atomic: the output data is written to the pipe as a contiguous sequence. Writes of more thanPIPE_BUF
bytes may be nonatomic: the kernel may interleave the data with data written by other processes. POSIX.1 requiresPIPE_BUF
to be at least 512 bytes. (On Linux,PIPE_BUF
is 4096 bytes.)
This is not quite clear. Does POSIX require that all writes less then PIPE_BUF
are atomic? Or this is true to pipes created with pipe(int[2], int)
only?