On 14.03.2015 03:40, Laurent Bercot wrote:
  - for reading: having several readers on the same pipe is the land
of undefined behaviour. You definitely don't want that.

... just for the curiosity:

On most systems it is perfectly possible to have multiple readers on a pipe, when all readers and writers be so polite to use the same message size (<= PIPE_BUF). On most (but not all Unix systems) the kernel guaranties not only atomicity for write operations, but also for read operations (not in POSIX, AFAIK).

With multiple readers you will get a load balancing. The first available reader get the next message from the pipe and has to handle this message. You can't predict, which process will receive a specific message, as this every process has to handle all types of incoming messages. This is usually true, when all readers share the same program.

With a small helper you can even fire up a new reader process when there is more data in the pipe, then sleep some time to let the new process pick up a message from the pipe, and then check the pipe again for more data, firing up the next reader (up to an upper limit of reader processes). Reader processes just die, when no more data is available in the pipe.

This belongs to pipes, and it does not matter if they are private or named (fifo).

--
Harald

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to