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