Re: sizeof PIPE_BUF

Johannes Stezenbach <[email protected]> Wed, 14 Jul 2010 11:06:59 +0200
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
On Sun, Feb 28, 2010 at 07:54:31PM +0100, Laurent Bercot wrote:
> > Note that the PIPE_BUF macro is not meant to indicate the size of the
> > kernel's pipe buffer.  Check the SUS description of write() for the
> > details of what PIPE_BUF means.  The buffer's size must be at least
> > PIPE_BUF to satisfy those requirements, but it may be larger.
> 
>  Indeed. And as far as I know, there's no strictly user-space way of
> knowing the size of the pipe buffer. When I needed to do this, I had
> to look deep into the Linux kernel headers, and didn't find anything
> either (even the kernel-space PIPE_SIZE macro is defined as PAGE_SIZE
> which is 4096). The 65536 value is probably hardcoded somewhere, but
> it's obviously not meant to be accessed by a userspace program.
> 
>  I guess it's one of the "the specific value is none of your business"
> cases, and strictly Single Unix-speaking, it's true; but with the
> introduction of the splice() family of system calls, it's still
> interesting to know that value. If Felix agrees, maybe he could
> suggest it on lkml.

FWIW, I just saw that Linux 2.6.35 adds F_GETPIPE_SZ and
F_SETPIPE_SZ fcntl.
http://www.kernel.org/doc/man-pages/online/pages/man2/fcntl.2.html
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=35f3d14d


Johannes