Re:Unix: When pipes get names
by hamburglar on Wednesday October 09, 2013 @01:00PM
(#6522408)
I don't understand why you'd do it, but sure, if you're determined to avoid pipes even in situations where they'd be really well suited to the problem, a scheme using files on a RAM-based filesystem and roll-your-own signaling/blocking/buffering could conceivably be made approximately equivalent, performance-wise, to a pipe.
Out of curiosity, is there some good reason you'd do this instead of just using a mechanism that's specifically made to solve this problem?
Well, for one thing, on some systems (e.g., OS X), /tmp is disk-backed.
But also, by writing out to /tmp on memory-backed systems, the lack of blocking means you grow memory use potentially indefinitely if the reader is slow or delayed for some reason. That will ultimately turn into swapping, which is just disk access again.
There's also no great way to truncate the beginning of a regular file.
The blocking/signalling is missing?
What's wrong with
$ ./producer > my_rambacked_file & $ tail -f my_rambacked_file > ./consumer
Well, okay, I guess this way you don't get a signal that the producer is finished.
The blocking/signalling is still missing though.