xref: /xnu-10002.41.9/bsd/man/man4/fd.4 (revision 699cd48037512bf4380799317ca44ca453c82f57)
1*699cd480SApple OSS Distributions.\"	$NetBSD: fd.4,v 1.3 1994/11/30 16:22:13 jtc Exp $
2*699cd480SApple OSS Distributions.\"
3*699cd480SApple OSS Distributions.\" Copyright (c) 1990, 1991, 1993
4*699cd480SApple OSS Distributions.\"	The Regents of the University of California.  All rights reserved.
5*699cd480SApple OSS Distributions.\"
6*699cd480SApple OSS Distributions.\" Redistribution and use in source and binary forms, with or without
7*699cd480SApple OSS Distributions.\" modification, are permitted provided that the following conditions
8*699cd480SApple OSS Distributions.\" are met:
9*699cd480SApple OSS Distributions.\" 1. Redistributions of source code must retain the above copyright
10*699cd480SApple OSS Distributions.\"    notice, this list of conditions and the following disclaimer.
11*699cd480SApple OSS Distributions.\" 2. Redistributions in binary form must reproduce the above copyright
12*699cd480SApple OSS Distributions.\"    notice, this list of conditions and the following disclaimer in the
13*699cd480SApple OSS Distributions.\"    documentation and/or other materials provided with the distribution.
14*699cd480SApple OSS Distributions.\" 3. All advertising materials mentioning features or use of this software
15*699cd480SApple OSS Distributions.\"    must display the following acknowledgement:
16*699cd480SApple OSS Distributions.\"	This product includes software developed by the University of
17*699cd480SApple OSS Distributions.\"	California, Berkeley and its contributors.
18*699cd480SApple OSS Distributions.\" 4. Neither the name of the University nor the names of its contributors
19*699cd480SApple OSS Distributions.\"    may be used to endorse or promote products derived from this software
20*699cd480SApple OSS Distributions.\"    without specific prior written permission.
21*699cd480SApple OSS Distributions.\"
22*699cd480SApple OSS Distributions.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*699cd480SApple OSS Distributions.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*699cd480SApple OSS Distributions.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*699cd480SApple OSS Distributions.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*699cd480SApple OSS Distributions.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*699cd480SApple OSS Distributions.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*699cd480SApple OSS Distributions.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*699cd480SApple OSS Distributions.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*699cd480SApple OSS Distributions.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*699cd480SApple OSS Distributions.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*699cd480SApple OSS Distributions.\" SUCH DAMAGE.
33*699cd480SApple OSS Distributions.\"
34*699cd480SApple OSS Distributions.\"     @(#)fd.4	8.1 (Berkeley) 6/9/93
35*699cd480SApple OSS Distributions.\"
36*699cd480SApple OSS Distributions.Dd June 9, 1993
37*699cd480SApple OSS Distributions.Dt FD 4
38*699cd480SApple OSS Distributions.Os
39*699cd480SApple OSS Distributions.Sh NAME
40*699cd480SApple OSS Distributions.Nm fd ,
41*699cd480SApple OSS Distributions.Nm stdin ,
42*699cd480SApple OSS Distributions.Nm stdout ,
43*699cd480SApple OSS Distributions.Nm stderr
44*699cd480SApple OSS Distributions.Nd file descriptor files
45*699cd480SApple OSS Distributions.Sh DESCRIPTION
46*699cd480SApple OSS DistributionsThe files
47*699cd480SApple OSS Distributions.Pa /dev/fd/0
48*699cd480SApple OSS Distributionsthrough
49*699cd480SApple OSS Distributions.Pa /dev/fd/#
50*699cd480SApple OSS Distributionsrefer to file descriptors which can be accessed through the file
51*699cd480SApple OSS Distributionssystem.
52*699cd480SApple OSS DistributionsIf the file descriptor is open and the mode the file is being opened
53*699cd480SApple OSS Distributionswith is a subset of the mode of the existing descriptor, the call:
54*699cd480SApple OSS Distributions.Bd -literal -offset indent
55*699cd480SApple OSS Distributionsfd = open("/dev/fd/0", mode);
56*699cd480SApple OSS Distributions.Ed
57*699cd480SApple OSS Distributions.Pp
58*699cd480SApple OSS Distributionsand the call:
59*699cd480SApple OSS Distributions.Bd -literal -offset indent
60*699cd480SApple OSS Distributionsfd = fcntl(0, F_DUPFD, 0);
61*699cd480SApple OSS Distributions.Ed
62*699cd480SApple OSS Distributions.Pp
63*699cd480SApple OSS Distributionsare equivalent.
64*699cd480SApple OSS Distributions.Pp
65*699cd480SApple OSS DistributionsOpening the files
66*699cd480SApple OSS Distributions.Pa /dev/stdin ,
67*699cd480SApple OSS Distributions.Pa /dev/stdout
68*699cd480SApple OSS Distributionsand
69*699cd480SApple OSS Distributions.Pa /dev/stderr
70*699cd480SApple OSS Distributionsis equivalent to the following calls:
71*699cd480SApple OSS Distributions.Bd -literal -offset indent
72*699cd480SApple OSS Distributionsfd = fcntl(STDIN_FILENO,  F_DUPFD, 0);
73*699cd480SApple OSS Distributionsfd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
74*699cd480SApple OSS Distributionsfd = fcntl(STDERR_FILENO, F_DUPFD, 0);
75*699cd480SApple OSS Distributions.Ed
76*699cd480SApple OSS Distributions.Pp
77*699cd480SApple OSS DistributionsFlags to the
78*699cd480SApple OSS Distributions.Xr open 2
79*699cd480SApple OSS Distributionscall other than
80*699cd480SApple OSS Distributions.Dv O_RDONLY ,
81*699cd480SApple OSS Distributions.Dv O_WRONLY
82*699cd480SApple OSS Distributionsand
83*699cd480SApple OSS Distributions.Dv O_RDWR
84*699cd480SApple OSS Distributionsare ignored.
85*699cd480SApple OSS Distributions.Sh FILES
86*699cd480SApple OSS Distributions.Bl -tag -width /dev/stderr -compact
87*699cd480SApple OSS Distributions.It Pa /dev/fd/#
88*699cd480SApple OSS Distributions.It Pa /dev/stdin
89*699cd480SApple OSS Distributions.It Pa /dev/stdout
90*699cd480SApple OSS Distributions.It Pa /dev/stderr
91*699cd480SApple OSS Distributions.El
92*699cd480SApple OSS Distributions.Sh SEE ALSO
93*699cd480SApple OSS Distributions.Xr tty 4
94