F_GETPIPE_SZ(2const)

πŸ’– F_GETPIPE_SZ, F_SETPIPE_SZ β€” get/set the capacity of a pipe πŸ’–

okay bestie, gather round, because this is one of those pages that lives in the 2const section of the Linux manual (that's the "constants that go with a syscall" girlies) and it's genuinely so useful once it clicks. it's giving "let me resize my pipe" energy. we're obsessed. 🫢


✨ LIBRARY ✨

Standard C library (libc, -lc) β€” the classic, no cap.


🌸 SYNOPSIS 🌸

#define _GNU_SOURCE
#include <fcntl.h>

int fcntl(int fd, F_SETPIPE_SZ, int arg);
int fcntl(int fd, F_GETPIPE_SZ);

like yes, it's just fcntl(2) with two very specific ops. iconic behavior honestly.


πŸ’… DESCRIPTION πŸ’…

F_SETPIPE_SZ

Change the capacity of the pipe referred to by fd to be at least arg bytes. (say it with me: at least, not "exactly", we'll get to why 😭)

An unprivileged process can adjust the pipe capacity to any value between the system page size and the limit defined in /proc/sys/fs/pipe-max-size (peep proc_sys_fs(5) for the deets).

  • Attempts to set the pipe capacity below the page size are silently rounded up to the page size. no drama, no error, it just does it. πŸ’«
  • Attempts by an unprivileged process to set the pipe capacity above the limit in /proc/sys/fs/pipe-max-size yield the error EPERM. rude, but fair.
  • A privileged process with CAP_SYS_RESOURCE can override the limit. main character energy. πŸ‘‘

When allocating the buffer for the pipe, the kernel may use a capacity larger than arg, if that is convenient for the implementation. (In the current implementation, the allocation is the next higher power-of-two page-size multiple of the requested size.) The actual capacity (in bytes) that is set is returned as the function result β€” so like, always check the return value, bestie, don't just assume you got what you asked for.

Attempting to set the pipe capacity smaller than the amount of buffer space currently used to store data produces the error EBUSY. can't shrink what's already full, that's just physics βœ‹

⚠️ Note that because of the way the pages of the pipe buffer are employed when data is written to the pipe, the number of bytes that can be written may be less than the nominal size, depending on the size of the writes. so the capacity number and the "how much can I actually shove in here" number are not always the same thing. lowkey important, don't get caught out. πŸ’€

F_GETPIPE_SZ

Return (as the function result) the capacity of the pipe referred to by fd. that's it. that's the whole vibe. you ask, it tells you. πŸŽ€


πŸ”₯ RETURN VALUE πŸ”₯

The pipe capacity. that's your answer, queen. πŸ’–

On error, -1 is returned, and errno is set to indicate the error. classic.


🌈 ERRORS 🌈

See fcntl(2) for the rest of the lore.

  • EBUSY β€” op is F_SETPIPE_SZ and the new pipe capacity specified in arg is smaller than the amount of buffer space currently used to store data in the pipe. the pipe is literally too full to shrink, bestie, respect it.
  • EPERM β€” op is F_SETPIPE_SZ and the soft or hard user pipe limit has been reached; see pipe(7). you hit the ceiling, no notes. 😭

⭐ STANDARDS ⭐

Linux. that's the standard. we're Linux-pilled here. 🐧


πŸ¦‹ HISTORY πŸ¦‹

Linux 2.6.35. vintage, but still serving looks. ✨


πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page, bestie!! this one came from the Linux man-pages, version 6.20, dated 2025-09-21. go forth and resize your pipes responsibly. mwah πŸ’‹πŸ’–βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms