Use pipe if possible, unless you expect large volumes of input to be created in the stream without reading. The pipe stores data in RAM, where a temporary file requires file system operations. fdsync in a file will be much more expensive than on a pipe. The pipe is also less vulnerable to safety problems caused by race conditions.
If your application cannot use channel semantics (requires a path to the file system to output it or a similar problem), try using a "named pipe" (also called FIFO).
source share