xref: /csrg-svn/share/man/man4/fd.4 (revision 47675)
1*47675Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California.
241534Sbostic.\" All rights reserved.
341534Sbostic.\"
441534Sbostic.\" %sccs.include.redist.man%
541534Sbostic.\"
6*47675Scael.\"     @(#)fd.4	5.2 (Berkeley) 03/28/91
741534Sbostic.\"
8*47675Scael.Dd
9*47675Scael.Dt FD 4
10*47675Scael.Os
11*47675Scael.Sh NAME
12*47675Scael.Nm fd ,
13*47675Scael.Nm stdin ,
14*47675Scael.Nm stdout ,
15*47675Scael.Nm stderr
16*47675Scael.Nd file descriptor files
17*47675Scael.Sh DESCRIPTION
1841534SbosticThe files
19*47675Scael.Pa /dev/fd/0
2041534Sbosticthrough
21*47675Scael.Pa /dev/fd/#
2241534Sbosticrefer to file descriptors which can be accessed through the file
2341534Sbosticsystem.
2441534SbosticIf the file descriptor is open and the mode the file is being opened
2541534Sbosticwith is a subset of the mode of the existing descriptor, the call:
26*47675Scael.Bd -literal -offset indent
2741534Sbosticfd = open("/dev/fd/0", mode);
28*47675Scael.Ed
29*47675Scael.Pp
3041534Sbosticand the call:
31*47675Scael.Bd -literal -offset indent
3241534Sbosticfd = fcntl(0, F_DUPFD, 0);
33*47675Scael.Ed
34*47675Scael.Pp
3541534Sbosticare equivalent.
36*47675Scael.Pp
3741534SbosticOpening the files
38*47675Scael.Pa /dev/stdin ,
39*47675Scael.Pa /dev/stdout
4041534Sbosticand
41*47675Scael.Pa /dev/stderr
4241534Sbosticis equivalent to the following calls:
43*47675Scael.Bd -literal -offset indent
4441534Sbosticfd = fcntl(STDIN_FILENO,  F_DUPFD, 0);
4541534Sbosticfd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
4641534Sbosticfd = fcntl(STDERR_FILENO, F_DUPFD, 0);
47*47675Scael.Ed
48*47675Scael.Pp
4941534SbosticFlags to the
50*47675Scael.Xr open 2
51*47675Scaelcall other than
52*47675Scael.Dv O_RDONLY ,
53*47675Scael.Dv O_WRONLY
54*47675Scaeland
55*47675Scael.Dv O_RDWR
56*47675Scaelare ignored.
57*47675Scael.Sh FILES
58*47675Scael.Bl -tag -width /dev/stderr -compact
59*47675Scael.It Pa /dev/fd/#
60*47675Scael.It Pa /dev/stdin
61*47675Scael.It Pa /dev/stdout
62*47675Scael.It Pa /dev/stderr
63*47675Scael.El
64*47675Scael.Sh SEE ALSO
65*47675Scael.Xr tty 4
66*47675Scael.Sh HISTORY
67*47675ScaelThe
68*47675Scael.Nm
69*47675Scaeldescriptor implementation
70*47675Scael.Ud
71