FD(4)
β¨ NAME β¨
okay so bestie, this is the FD(4) page, and it's all about fd, plus its bestie aliases stdin, stdout, and stderr β aka the file descriptor files. iconic, honestly. π
π¦ DESCRIPTION π¦
The files /dev/fd/0 through /dev/fd/# refer to file descriptors that you can access through the file system. no cap. If the file descriptor is open and the mode the file is being opened with is a subset of the mode of the existing descriptor, then this call:
fd = open("/dev/fd/0", mode);
and this call:
fd = fcntl(0, F_DUPFD, 0);
are equivalent. literally the same vibe. β¨
Opening the files /dev/stdin, /dev/stdout and /dev/stderr is equivalent to the following calls, fr fr:
fd = fcntl(STDIN_FILENO, F_DUPFD, 0);
fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
fd = fcntl(STDERR_FILENO, F_DUPFD, 0);
Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored. not me stressing about them, because the page says they're ignored. π
πΈ IMPLEMENTATION NOTES πΈ
By default, /dev/fd is provided by devfs(4), which provides nodes for the first three file descriptors. Some sites may require nodes for additional file descriptors; these can be made available by mounting fdescfs(4) on /dev/fd. so if you need more fd nodes, that's the move. π«Ά
π FILES π
/dev/fd/#/dev/stdin/dev/stdout/dev/stderr
π SEE ALSO π
devfs(4), fdescfs(4), tty(4) β go read those too, bestie. iykyk. π
This page came from Debian, dated June 9, 1993, and it's the FD(4) manual page. slay and goodbye π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1990, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms