V8/usr/man/man4/fd.4

Compare this file to the similar file:
Show the results in this format:

.TH FD 4
.SH NAME
fd, stdin, stdout, stderr, tty \- file descriptor files
.SH DESCRIPTION
These files, conventionally called
.I /dev/fd/\^0, /dev/fd/1, ... /dev/fd/127,
refer to files accessible through file descriptors.
If file descriptor 
.I n
is open,
these two system calls have the same effect:
.IP
fd = open("/dev/fd/\fIn\fR", mode);
.br
fd = dup(\fIn\fR\|);
.LP
.IR Creat (2)
is equivalent to
.I open, and
.I mode
is ignored.
As with
.IR dup ,
subsequent IO on
.I fd
fails unless the original file descriptor
allows the read or write operation.
.PP
Entry
.I /dev/fd/3
is conventionally the `control terminal' of the process group
to which the present process belongs; see
.IR stream (4).
.PP
The entries
.I /dev/stdin, /dev/stdout,
.I /dev/stderr,
and
.I /dev/tty
are conventionally linked to
.I /dev/fd/\^0, /dev/fd/1,
.I /dev/fd/2,
and
.I /dev/fd/3
respectively.
.PP
.SH SEE ALSO
open(2), dup(2), stream(4)
.SH DIAGNOSTICS
.I Open
returns \-1 if the related file descriptor is not open.