Search notes:
/dev/fd/
/dev/fd
contains numbered files (0
, 1
, 2
, …), each corresponding to a file descriptor.
The directory
/dev/fd
is (or should be) symlinked to
/proc/self/fd
:
$ ls -ld /dev/fd
lrwxrwxrwx 1 root root 13 Jul 24 06:48 /dev/fd -> /proc/self/fd
The files under /proc/self/fd
are symlinked as well:
$ ls -l /proc/self/fd
lrwx------ 1 rene rene 64 Aug 10 09:08 0 -> /dev/pts/0
lrwx------ 1 rene rene 64 Aug 10 09:08 1 -> /dev/pts/0
lrwx------ 1 rene rene 64 Aug 10 09:08 2 -> /dev/pts/0
lr-x------ 1 rene rene 64 Aug 10 09:08 3 -> /proc/274/fd
Equivalent calls
As per
man 4 stdin
, the following calls are equivalent:
fd = open("/dev/fd/0", mode);
fd = fcntl(0, F_DUPFD, 0);
And also, per the same
man page, opening
/dev/stdin
,
/dev/stdout
and
/dev/stderr
is equivalent to
fd = fcntl(STDIN_FILENO, F_DUPFD, 0);
fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
fd = fcntl(STDERR_FILENO, F_DUPFD, 0);