Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>tee will exit once it writes the last bit of input to the last output pipe and closes it (that is, the unnamed pipes created by bash, not your fifo, aka "named pipe"). It has no need to wait for the processes reading the pipes to finish; indeed, it has no idea that it is even writing to pipes. Since pipes have buffers, it's quite likely that tee finishes writing before the processes at the other end have finished reading. So the script will write 'EOP' into the fifo, causing the read loop to terminate. That will close the fifo's only reader, and all the cfv processes will get SIGPIPE when they next try to write to stdout.</p> <p>The obvious question to ask here is why you don't just run three (or N) independent processes reading the file and computing different summaries. If "the file" were actually being generated on the fly or downloaded from some remote site, or some other slow process, it might make sense to do things the way you're trying to do them, but if the file is present on local disk, it's pretty likely that only one disk access will actually happen; the lagging summarizers will read the file from the buffer cache. If that's all you need, GNU parallel should work fine, or you can just start up the processes in bash (with &amp;) and then wait for them. YMMV but I would think that either of these solutions will be less resource-intensive than setting up all those pipes and simulating the buffer cache in userland with tee.</p> <p>By the way, if you want to serialize output from multiple processes, you can use the flock utility. Just using a fifo isn't enough; there is no guarantee that the processes writing to the fifo will write entire lines atomically and if you knew they did that, you wouldn't need the fifo.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload