0
votes

As stated in pipe's Linux man page, given a pipe/FIFO that was opened properly for reading & writng, if the write end is closed, then "an attempt to read(2) from the pipe will see end-of-file (read(2) will return 0)". My question is, let's say I've written some data to the pipe (which should now be stored in a kernel buffer), and I've then closed the writing end before the reading end managed to read the data, will a following attempt to read from the file still automatically get EOF, or will the reader be able to first read the data in the kernel buffer and only afterwards get EOF?

1
The reader will read the data that is in the buffer. When all of the data is read, read will return 0 to indicate end of file. Note that if there is another reader, only one of the readers will see any given byte of data. - William Pursell

1 Answers

2
votes

The data still in the pipe is read first before an EOF is signaled.