FD(4)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

✨ 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms