1afe61c15SRodney W. Grimes.\" Copyright (c) 1990, 1991, 1993 2afe61c15SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 3afe61c15SRodney W. Grimes.\" 4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions 6afe61c15SRodney W. Grimes.\" are met: 7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 8afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 10afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 11afe61c15SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 12dda5b397SEitan Adler.\" 3. Neither the name of the University nor the names of its contributors 13afe61c15SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 14afe61c15SRodney W. Grimes.\" without specific prior written permission. 15afe61c15SRodney W. Grimes.\" 16afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19afe61c15SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26afe61c15SRodney W. Grimes.\" SUCH DAMAGE. 27afe61c15SRodney W. Grimes.\" 28afe61c15SRodney W. Grimes.Dd June 9, 1993 29afe61c15SRodney W. Grimes.Dt FD 4 30afe61c15SRodney W. Grimes.Os 31afe61c15SRodney W. Grimes.Sh NAME 32afe61c15SRodney W. Grimes.Nm fd , 33afe61c15SRodney W. Grimes.Nm stdin , 34afe61c15SRodney W. Grimes.Nm stdout , 35afe61c15SRodney W. Grimes.Nm stderr 36afe61c15SRodney W. Grimes.Nd file descriptor files 37afe61c15SRodney W. Grimes.Sh DESCRIPTION 38afe61c15SRodney W. GrimesThe files 39afe61c15SRodney W. Grimes.Pa /dev/fd/0 40afe61c15SRodney W. Grimesthrough 41afe61c15SRodney W. Grimes.Pa /dev/fd/# 42afe61c15SRodney W. Grimesrefer to file descriptors which can be accessed through the file 43afe61c15SRodney W. Grimessystem. 44afe61c15SRodney W. GrimesIf the file descriptor is open and the mode the file is being opened 45afe61c15SRodney W. Grimeswith is a subset of the mode of the existing descriptor, the call: 46afe61c15SRodney W. Grimes.Bd -literal -offset indent 47afe61c15SRodney W. Grimesfd = open("/dev/fd/0", mode); 48afe61c15SRodney W. Grimes.Ed 49afe61c15SRodney W. Grimes.Pp 50afe61c15SRodney W. Grimesand the call: 51afe61c15SRodney W. Grimes.Bd -literal -offset indent 52afe61c15SRodney W. Grimesfd = fcntl(0, F_DUPFD, 0); 53afe61c15SRodney W. Grimes.Ed 54afe61c15SRodney W. Grimes.Pp 55afe61c15SRodney W. Grimesare equivalent. 56afe61c15SRodney W. Grimes.Pp 57afe61c15SRodney W. GrimesOpening the files 58afe61c15SRodney W. Grimes.Pa /dev/stdin , 59afe61c15SRodney W. Grimes.Pa /dev/stdout 60afe61c15SRodney W. Grimesand 61afe61c15SRodney W. Grimes.Pa /dev/stderr 62afe61c15SRodney W. Grimesis equivalent to the following calls: 63afe61c15SRodney W. Grimes.Bd -literal -offset indent 64afe61c15SRodney W. Grimesfd = fcntl(STDIN_FILENO, F_DUPFD, 0); 65afe61c15SRodney W. Grimesfd = fcntl(STDOUT_FILENO, F_DUPFD, 0); 66afe61c15SRodney W. Grimesfd = fcntl(STDERR_FILENO, F_DUPFD, 0); 67afe61c15SRodney W. Grimes.Ed 68afe61c15SRodney W. Grimes.Pp 69afe61c15SRodney W. GrimesFlags to the 70afe61c15SRodney W. Grimes.Xr open 2 71afe61c15SRodney W. Grimescall other than 72afe61c15SRodney W. Grimes.Dv O_RDONLY , 73afe61c15SRodney W. Grimes.Dv O_WRONLY 74afe61c15SRodney W. Grimesand 75afe61c15SRodney W. Grimes.Dv O_RDWR 76afe61c15SRodney W. Grimesare ignored. 779d6c8573SRobert Watson.Sh IMPLEMENTATION NOTES 789d6c8573SRobert WatsonBy default, 799d6c8573SRobert Watson.Pa /dev/fd 809d6c8573SRobert Watsonis provided by 81*1a720cbeSAlexander Ziaee.Xr devfs 4 , 829d6c8573SRobert Watsonwhich provides nodes for the first three file descriptors. 839d6c8573SRobert WatsonSome sites may require nodes for additional file descriptors; these can be 849d6c8573SRobert Watsonmade available by mounting 85*1a720cbeSAlexander Ziaee.Xr fdescfs 4 869d6c8573SRobert Watsonon 879d6c8573SRobert Watson.Pa /dev/fd . 88afe61c15SRodney W. Grimes.Sh FILES 89afe61c15SRodney W. Grimes.Bl -tag -width /dev/stderr -compact 90afe61c15SRodney W. Grimes.It Pa /dev/fd/# 91afe61c15SRodney W. Grimes.It Pa /dev/stdin 92afe61c15SRodney W. Grimes.It Pa /dev/stdout 93afe61c15SRodney W. Grimes.It Pa /dev/stderr 94afe61c15SRodney W. Grimes.El 95afe61c15SRodney W. Grimes.Sh SEE ALSO 96*1a720cbeSAlexander Ziaee.Xr devfs 4 , 97*1a720cbeSAlexander Ziaee.Xr fdescfs 4 , 98*1a720cbeSAlexander Ziaee.Xr tty 4 99