DUP(3)
π DUP(3) β Library Functions Manual π
πΈ NAME πΈ
dup β duplicate an open file descriptor. bestie, itβs literally giving βsame file, new descriptorβ energy π
β¨ SYNOPSIS β¨
#include <u.h>
#include <libc.h>
int dup(int oldfd, int newfd)
π DESCRIPTION π
Okay so picture this: you give dup a file descriptor called oldfd, and that descriptor is referring to an open file. dup returns a new file descriptor that refers to the same file. iconic behavior, no cap π«Ά
If newfd is -1, the system chooses the lowest available file descriptor. Otherwise, dup will use newfd for the new file descriptor β and yes, it closes any old file associated with newfd ππ
π¦ SOURCE π¦
/src/lib9/dup.c
π DIAGNOSTICS π
Sets errstr. thatβs the diagnostic moment, bestie β¨
π BUGS π
To avoid name conflicts with the underlying system, dup is a preprocessor macro defined as p9dup; see intro(3). iykyk, the macro girlies know π
Sign-off time: the bottom-of-page footer is literally just DUP(3) β thatβs the cute footer energy, mwah πβ¨
π¦ 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