Depende de quanto cada processo está escrevendo (assumindo que seu sistema operacional é compatível com POSIX a esse respeito). De write()
:
Write requests to a pipe or FIFO shall be handled in the same way as a regular file with the following exceptions:
[...]
- Write requests of {PIPE_BUF} bytes or less shall not be interleaved with data from other processes doing writes on the same pipe. Writes of greater than {PIPE_BUF} bytes may have data interleaved, on arbitrary boundaries, with writes by other processes, whether or not the O_NONBLOCK flag of the file status flags is set.
Também na seção Rationale sobre canais e FIFOs:
- Atomic/non-atomic: A write is atomic if the whole amount written in one operation is not interleaved with data from any other process. This is useful when there are multiple writers sending data to a single reader. Applications need to know how large a write request can be expected to be performed atomically. This maximum is called {PIPE_BUF}. This volume of POSIX.1-2008 does not say whether write requests for more than {PIPE_BUF} bytes are atomic, but requires that writes of {PIPE_BUF} or fewer bytes shall be atomic.
O valor se PIPE_BUF
é definido por cada implementação, mas o mínimo é de 512 bytes (veja limits.h
). No Linux, são 4096 bytes (veja pipe(7)
).