.\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)fd.4 8.1 (Berkeley) 06/09/93 .\" .Dd .Dt FD 4 .Os .Sh NAME .Nm fd , .Nm stdin , .Nm stdout , .Nm stderr .Nd file descriptor files .Sh DESCRIPTION The files .Pa /dev/fd/0 through .Pa /dev/fd/# refer to file descriptors which can be accessed through the file system. 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, the call: .Bd -literal -offset indent fd = open("/dev/fd/0", mode); .Ed .Pp and the call: .Bd -literal -offset indent fd = fcntl(0, F_DUPFD, 0); .Ed .Pp are equivalent. .Pp Opening the files .Pa /dev/stdin , .Pa /dev/stdout and .Pa /dev/stderr is equivalent to the following calls: .Bd -literal -offset indent fd = fcntl(STDIN_FILENO, F_DUPFD, 0); fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); fd = fcntl(STDERR_FILENO, F_DUPFD, 0); .Ed .Pp Flags to the .Xr open 2 call other than .Dv O_RDONLY , .Dv O_WRONLY and .Dv O_RDWR are ignored. .Sh FILES .Bl -tag -width /dev/stderr -compact .It Pa /dev/fd/# .It Pa /dev/stdin .It Pa /dev/stdout .It Pa /dev/stderr .El .Sh SEE ALSO .Xr tty 4