io_pipe(3)
β¨ io_pipe(3) β¨
okay bestie, so this one lives in the Library Functions Manual and it's literally the origin story of every Unix pipe ever π
πΈ NAME πΈ
io_pipe β create a Unix pipe, that's it, that's the whole job π«Ά
π SYNTAX π
#include <libowfat/io.h>
int io_pipe(int64 pfd[2]);
π¦ DESCRIPTION π¦
io_pipe creates a brand new UNIX "pipe." β¨ A pipe can receive data and provide data β so like, any bytes you write into the pipe can then be read back out of the pipe, in the exact same order. first in, first out, no cap π
A pipe is typically stored in an 8192-byte memory buffer, but the exact number lowkey depends on the UNIX kernel β it's giving "your mileage may vary" π Bytes get written to the end of the buffer and read from the beginning of the buffer. Once a byte has been read, it's eliminated from the buffer, which makes space for another byte to be written. So readers cannot "rewind" a pipe to read old data β there's no rewind button, bestie, the past is gone π
Once 8192 bytes have been written to the buffer, the pipe will not be ready for further writing until some of the bytes have been read. And once all the bytes written have been read, the pipe will not be ready for further reading until more bytes are written. it's a whole balance situation βοΈ
io_pipe sets d[0] to the number of a new descriptor reading from the pipe, and sets d[1] to the number of a new descriptor writing to the pipe. Then it returns 1 to indicate success π
If something goes wrong, io_pipe returns 0, setting errno to indicate the error. In that case it frees any memory that it allocated for the new pipe, and it leaves d alone β so no half-built pipe nonsense, it cleans up after itself like a functioning adult π
β οΈ heads up bestie: on the error path you get0back,errnogets set, the memory gets freed, anddstays untouched. don't go reading fromdlike it's real, okay? π
π SEE ALSO π
and that's the whole page, fr fr π big slay to the Library Functions Manual for hosting io_pipe(3), mwah, go build a pipe, you've got this ππβ¨
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms