PIPE(3)
π PIPE(3) β Library Functions Manual π
okay bestie, welcome to the pipe page, this is PIPE(3) from the Library Functions Manual and honestly it's giving "small function, chaotic lore" energy so let's get into it π«Ά
β¨ NAME β¨
pipe β create an interprocess channel π
πΈ SYNOPSIS πΈ
#include <u.h>
#include <libc.h>
int pipe(int fd[2])
π¦ DESCRIPTION π¦
okay so Pipe creates a buffered channel for interprocess I/O communication β¨. That's the whole vibe. Two file descriptors come back to you inside fd β literally two, no more no less, it's a duo π
.
And here's the cute part: data written to fd[1] is available for reading from fd[0], and data written to fd[0] is available for reading from fd[1]. It goes both ways bestie, it's mutual π.
Once the pipe is established, cooperating processes created by subsequent fork(2) calls may pass data through the pipe with read and write calls. group chat, but for processes, no cap π
When all the data has been read from a pipe and the writer has closed the pipe or exited, read(3) will return 0 bytes β that's the "they left the chat" signal, iconic π.
β οΈ Writes to a pipe with no reader will generate a note sys: write on closed pipe. like yelling into a void, but the void files a complaint π
π§ SOURCE π§
/src/lib9/pipe.c
β SEE ALSO β
(iykyk, go read them, they're literally connected π)
π DIAGNOSTICS π
Sets errstr. that's it, that's the diagnostic, she's efficient π¦
π BUGS π
okay this section is a lot, buckle up:
- If a
reador awriteof a pipe is interrupted, some unknown number of bytes may have been transferred. like, unknown unknown. we don't know. nobody knows. π Pipeis a macro defined asp9pipeto avoid name conflicts with Unix'spipesystem call. it's a nickname situation π- Unix pipes are not guaranteed to be bidirectional. In order to ensure a bidirectional channel,
p9pipecreates Unix domain sockets via thesocketpair(2)instead of Unix pipes. so she's not even a pipe pipe, she's a socket in a trench coat π§₯β¨ - The implementation of pipes as Unix domain sockets causes problems with some Unix implementations of
/dev/fd, Unix'sdupdevice. If a Unix domain socket is open as file descriptor 0, some implementations disallow the opening of/dev/fd/0; instead one mustconnect(2)to it. the audacity honestly π€ - If this functionality is important (as it is for
rc(1)), one must#undef pipeand fall back on the (possibly unidirectional) Unix pipes. so you gotta let go of the good version to get the compatible version, we've all been there π
πΈ that's the whole page bestie, go make some channels πΈ
π fromPIPE(3), Library Functions Manual, footer saysPIPE(3)and like, that's the version and date situation β signed off with love, xoxo ππ«Ά
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms