xref: /illumos-gate/usr/src/man/man4fs/fd.4fs (revision bbf215553c7233fbab8a0afdf1fac74c44781867)
1*bbf21555SRichard Lowe.\"
2*bbf21555SRichard Lowe.\" Copyright (c) 1993, Sun Microsystems, Inc. All Rights Reserved.
3*bbf21555SRichard Lowe.\" Copyright 1989 AT&T
4*bbf21555SRichard Lowe.\" Copyright 2021 Oxide Computer Company
5*bbf21555SRichard Lowe.\"
6*bbf21555SRichard Lowe.\" The contents of this file are subject to the terms of the
7*bbf21555SRichard Lowe.\" Common Development and Distribution License (the "License").
8*bbf21555SRichard Lowe.\" You may not use this file except in compliance with the License.
9*bbf21555SRichard Lowe.\"
10*bbf21555SRichard Lowe.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*bbf21555SRichard Lowe.\" or http://www.opensolaris.org/os/licensing.
12*bbf21555SRichard Lowe.\" See the License for the specific language governing permissions
13*bbf21555SRichard Lowe.\" and limitations under the License.
14*bbf21555SRichard Lowe.\"
15*bbf21555SRichard Lowe.\" When distributing Covered Code, include this CDDL HEADER in each
16*bbf21555SRichard Lowe.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*bbf21555SRichard Lowe.\" If applicable, add the following below this CDDL HEADER, with the
18*bbf21555SRichard Lowe.\" fields enclosed by brackets "[]" replaced with your own identifying
19*bbf21555SRichard Lowe.\" information: Portions Copyright [yyyy] [name of copyright owner]
20*bbf21555SRichard Lowe.\"
21*bbf21555SRichard Lowe.Dd July 3, 1990
22*bbf21555SRichard Lowe.Dt FD 4FS
23*bbf21555SRichard Lowe.Os
24*bbf21555SRichard Lowe.Sh NAME
25*bbf21555SRichard Lowe.Nm fd ,
26*bbf21555SRichard Lowe.Nm stdin ,
27*bbf21555SRichard Lowe.Nm stdout ,
28*bbf21555SRichard Lowe.Nm stderr
29*bbf21555SRichard Lowe.Nd file descriptor files
30*bbf21555SRichard Lowe.Sh DESCRIPTION
31*bbf21555SRichard LoweThese files, conventionally called
32*bbf21555SRichard Lowe.Pa /dev/fd/0 ,
33*bbf21555SRichard Lowe.Pa /dev/fd/1 ,
34*bbf21555SRichard Lowe.Pa /dev/fd/2 ,
35*bbf21555SRichard Loweand so on, refer to files accessible through file descriptors.
36*bbf21555SRichard LoweIf file descriptor
37*bbf21555SRichard Lowe.Em n
38*bbf21555SRichard Loweis open, these two system calls have the same
39*bbf21555SRichard Loweeffect:
40*bbf21555SRichard Lowe.Bd -literal -offset indent
41*bbf21555SRichard Lowefd = open("/dev/fd/<n>", mode);
42*bbf21555SRichard Lowefd = dup(n);
43*bbf21555SRichard Lowe.Ed
44*bbf21555SRichard Lowe.Pp
45*bbf21555SRichard LoweOn these files
46*bbf21555SRichard Lowe.Xr creat 2
47*bbf21555SRichard Loweis equivalent to
48*bbf21555SRichard Lowe.Xr open 2 ,
49*bbf21555SRichard Loweand
50*bbf21555SRichard Lowe.Fa mode
51*bbf21555SRichard Loweis
52*bbf21555SRichard Loweignored.
53*bbf21555SRichard LoweAs with
54*bbf21555SRichard Lowe.Xr dup 2 ,
55*bbf21555SRichard Lowesubsequent reads or writes on
56*bbf21555SRichard Lowe.Em fd
57*bbf21555SRichard Lowefail unless the original file descriptor allows the operations.
58*bbf21555SRichard Lowe.Pp
59*bbf21555SRichard LoweFor convenience in referring to standard input, standard output, and standard
60*bbf21555SRichard Loweerror, an additional set of names is provided:
61*bbf21555SRichard Lowe.Pa /dev/stdin
62*bbf21555SRichard Loweis a synonym
63*bbf21555SRichard Lowefor
64*bbf21555SRichard Lowe.Pa /dev/fd/0 ,
65*bbf21555SRichard Lowe.Pa /dev/stdout
66*bbf21555SRichard Lowefor
67*bbf21555SRichard Lowe.Pa /dev/fd/1 ,
68*bbf21555SRichard Loweand
69*bbf21555SRichard Lowe.Pa /dev/stderr
70*bbf21555SRichard Lowefor
71*bbf21555SRichard Lowe.Pa /dev/fd/2 .
72*bbf21555SRichard Lowe.Sh DIAGNOSTICS
73*bbf21555SRichard Lowe.Xr open 2
74*bbf21555SRichard Lowereturns
75*bbf21555SRichard Lowe.Sy -1
76*bbf21555SRichard Loweand
77*bbf21555SRichard Lowe.Va errno
78*bbf21555SRichard Loweis set to
79*bbf21555SRichard Lowe.Er EBADF
80*bbf21555SRichard Loweif the associated file descriptor is not open.
81*bbf21555SRichard Lowe.Sh SEE ALSO
82*bbf21555SRichard Lowe.Xr creat 2 ,
83*bbf21555SRichard Lowe.Xr dup 2 ,
84*bbf21555SRichard Lowe.Xr open 2
85