[PATCH] pipe.7: document read()s with O_NONBLOCK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Which don't behave like you may expect them to.

Quoth Issue 8 Draft 3:
60746  When attempting to read from an empty pipe or FIFO:
60747    • If no process has the pipe open for writing, read( ) shall return 0 to indicate end-of-file.
60748    • If some process has the pipe open for writing and O_NONBLOCK is set, read( ) shall return
60749      −1 and set errno to [EAGAIN].
60750    • If some process has the pipe open for writing and O_NONBLOCK is clear, read( ) shall
60751      block the calling thread until some data is written or the pipe is closed by all processes that
60752      had the pipe open for writing.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx>
---
 man7/pipe.7 | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/man7/pipe.7 b/man7/pipe.7
index c3e06bdab..fb2ed61cd 100644
--- a/man7/pipe.7
+++ b/man7/pipe.7
@@ -56,12 +56,20 @@ .SS I/O on pipes and FIFOs
 .BR write (2)
 blocks until sufficient data has been read from the pipe
 to allow the write to complete.
+.PP
 Nonblocking I/O is possible by using the
 .BR fcntl (2)
 .B F_SETFL
 operation to enable the
 .B O_NONBLOCK
-open file status flag.
+open file status flag or by opening a
+.BR fifo (7)
+with
+.BR O_NONBLOCK .
+There are oddities if reading and no data is available:
+if any process has the pipe open for writing, reads fail with
+.BR EAGAIN ;
+otherwise\[em]with no potential writers\[em]reads succeed and return empty.
 .PP
 The communication channel provided by a pipe is a
 .IR "byte stream" :
-- 
2.39.2

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux