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

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

 



On 2023-07-15 20:36, наб wrote:
> Which don't behave like you may expect them to;
> unprimed, I expected the natural extension of either:
> files   (being a  filesystem object), always returning 0 if no data, or
> sockets (being an IPC mechanism),     always EAGAINing   if no data.
> 
> The pipe semantics make sense of course ‒ pipes can be modelled as
> sockets if there aren't writers, but files if there are; indeed,
> this makes sense as the writer continuously appending a sliding
> "window" over a file ‒ but they're unique amongst the UNIX file types,
> but arriving at that specific interaction table is non-obvious,
> especially to a user.
> 
> 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>

Applied.  Thanks!

> ---
>  man7/pipe.7 | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/man7/pipe.7 b/man7/pipe.7
> index c3e06bdab..91554fa3c 100644
> --- a/man7/pipe.7
> +++ b/man7/pipe.7
> @@ -56,12 +56,19 @@ .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 .
> +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" :

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital 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