Can someone please clarify behavior of the named pipes (particularly in Linux) regarding buffering data and blocking.
mkfifo pipe1
cat pipe1 # blocks until another process sends data
echo "hi" > pipe1 # running this in the other tty unblocks waiting "cat"
and on contrary (this could be run after previous experiment on the same pipe supposedly):
echo "ping" > pipe1 # blocks, seemingly until another process reads the data
cat pipe1 # unblocks the "echo" above, if run from another tty
Do these both examples block until the “other end” is read/written - or just until the other end is opened at all?
Does the pipe have internal buffer (so that some further writing could be done without block)?
If the process on the “reading” end finishes while some data were not yet consumed from the pipe (or the “writing” process send some more before also finishing) - are these extra data going to appear when the next reading process opens the pipe?
Do we recognize some kind of EOF on the reading end when writing process finishes and we consumed all the data it produced (even though later we can reuse the pipe, writing to it from the other process)?
Sorry if questions are not well-relevant due to misunderstanding of the mechanism. Please feel free to simply provide a link to some advanced documentation.