The material in this document is provided AS IS, without any expressed or implied warranty, or claim of fitness for a particular purpose. Example Standard input redirection.
Using Message Queues One of the problems with pipes is that it is up to you, as a programmer, to establish the protocol.
The following four lines include C headers specific to OCaml installed by the distribution. On many systems, pipes will fill up after you write about 10K to them without reading anything out.
To avoid this, we need to use some locking mechanism - SysV semaphores used as mutexes come to mind here. As you can see, when it goes through the function, it always decrements the value of the semaphore by 1, and then increases it by 1.
Sometimes one of the readers get everything. One problem might be that copying a file takes a lot of time, and thus locking the spool directory for a long while.