The file object itself is created in the filesystem, but no data is stored in a file system. From the mkpipe(3) manpage:
A FIFO special file is similar to a pipe, except that it is created in
a different way. Instead of being an anonymous communications channel,
a FIFO special file is entered into the file system by calling
mkfifo().
About the only time the data might be stored on disk is during hibernation when memory is written to the swap space, including buffers - however this an corner case.
As for the cause, use strace
.
tail -f | strace bash >> foo
The second echo echo hello > pToB
gives me then this:
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(0, "e", 1) = 1
read(0, "c", 1) = 1
read(0, "h", 1) = 1
read(0, "o", 1) = 1
read(0, " ", 1) = 1
read(0, "h", 1) = 1
read(0, "e", 1) = 1
read(0, "l", 1) = 1
read(0, "l", 1) = 1
read(0, "o", 1) = 1
read(0, "\n", 1) = 1
write(1, "hello\n", 6) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=3299, si_uid=1000} ---
+++ killed by SIGPIPE +++
So, the second time it tries to write hello\n, it gets a broken pipe error; that's why you can't read hello (it was never written), and bash quits so that's the end of it.
You'd have to use something that keeps the pipe open, I guess.
How about this?
(while read myline; do echo $myline; done) < pToP
For more background information, man 7 pipe
may be relevant, it describes the various error cases around pipes.
Best Answer
No they're written to disk. The command
mkfifo pipe21
creates the corresponding device on your filesystem. Often times these devices are kept under/dev
but named pipes (aka. FIFOS) don't necessarily have to be kept in this directory.excerpt from wikipedia article
Example
Make a FIFO:
Check out the FIFO device:
Delete the device:
References