From: "Štěpán Němec" <stepnem@smrk.net>
To: libc-alpha@sourceware.org
Subject: [PATCH] manual: Drop incorrect statement on PIPE_BUF and blocking writes
Date: Mon, 25 Mar 2024 09:59:27 +0100 [thread overview]
Message-ID: <20240325085927.2041034-1-stepnem@smrk.net> (raw)
Typical Linux defaults are 4096 bytes of PIPE_BUF and 65536 bytes of
kernel pipe buffer; the latter, not the former, limits the amount
of data writable without blocking. E.g., observe the different
behavior of the following two command lines (assuming the above
defaults):
{ dd if=/dev/zero bs=65536 count=1 2>/dev/null;
echo 'all written' >&2; } |
{ sleep 1; wc -c; }
{ dd if=/dev/zero bs=65537 count=1 2>/dev/null;
echo 'all written' >&2; } |
{ sleep 1; wc -c; }
Only the latter waits 1s before printing 'all written', due to the
number of bytes being written exceeding the kernel pipe buffer.
PIPE_BUF (still only 4096 bytes) is irrelevant here.
From pipe(7):
Before Linux 2.6.11, the capacity of a pipe was the same as the system
page size (e.g., 4096 bytes on i386). Since Linux 2.6.11, the pipe ca‐
pacity is 16 pages (i.e., 65,536 bytes in a system with a page size of
4096 bytes). Since Linux 2.6.35, the default pipe capacity is 16
pages, but the capacity can be queried and set using the fcntl(2)
F_GETPIPE_SZ and F_SETPIPE_SZ operations. See fcntl(2) for more infor‐
mation.
---
manual/pipe.texi | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/manual/pipe.texi b/manual/pipe.texi
index 483c40c5c3dd..8a9a275cafe7 100644
--- a/manual/pipe.texi
+++ b/manual/pipe.texi
@@ -312,8 +312,7 @@
Reading or writing a larger amount of data may not be atomic; for
example, output data from other processes sharing the descriptor may be
-interspersed. Also, once @code{PIPE_BUF} characters have been written,
-further writes will block until some characters are read.
+interspersed.
@xref{Limits for Files}, for information about the @code{PIPE_BUF}
parameter.
base-commit: dc1a77269c971652a8a5167ec366792eae052e65
--
2.44.0
next reply other threads:[~2024-03-25 9:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 8:59 Štěpán Němec [this message]
2024-03-25 11:46 ` [PATCH] manual: Drop incorrect statement on PIPE_BUF and blocking writes Florian Weimer
2024-03-25 12:13 ` Štěpán Němec
2024-03-25 16:20 ` Zack Weinberg
2024-03-25 21:32 ` Štěpán Němec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240325085927.2041034-1-stepnem@smrk.net \
--to=stepnem@smrk.net \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).