1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)fd.4 5.2 (Berkeley) 03/28/91 7.\" 8.Dd 9.Dt FD 4 10.Os 11.Sh NAME 12.Nm fd , 13.Nm stdin , 14.Nm stdout , 15.Nm stderr 16.Nd file descriptor files 17.Sh DESCRIPTION 18The files 19.Pa /dev/fd/0 20through 21.Pa /dev/fd/# 22refer to file descriptors which can be accessed through the file 23system. 24If the file descriptor is open and the mode the file is being opened 25with is a subset of the mode of the existing descriptor, the call: 26.Bd -literal -offset indent 27fd = open("/dev/fd/0", mode); 28.Ed 29.Pp 30and the call: 31.Bd -literal -offset indent 32fd = fcntl(0, F_DUPFD, 0); 33.Ed 34.Pp 35are equivalent. 36.Pp 37Opening the files 38.Pa /dev/stdin , 39.Pa /dev/stdout 40and 41.Pa /dev/stderr 42is equivalent to the following calls: 43.Bd -literal -offset indent 44fd = fcntl(STDIN_FILENO, F_DUPFD, 0); 45fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); 46fd = fcntl(STDERR_FILENO, F_DUPFD, 0); 47.Ed 48.Pp 49Flags to the 50.Xr open 2 51call other than 52.Dv O_RDONLY , 53.Dv O_WRONLY 54and 55.Dv O_RDWR 56are ignored. 57.Sh FILES 58.Bl -tag -width /dev/stderr -compact 59.It Pa /dev/fd/# 60.It Pa /dev/stdin 61.It Pa /dev/stdout 62.It Pa /dev/stderr 63.El 64.Sh SEE ALSO 65.Xr tty 4 66.Sh HISTORY 67The 68.Nm 69descriptor implementation 70.Ud 71