2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
7 .\" This notice shall appear on any product containing this material.
8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
11 .TH FDOPEN 3C "Apr 18, 2006"
13 fdopen \- associate a stream with a file descriptor
19 \fBFILE *\fR\fBfdopen\fR(\fBint\fR \fIfildes\fR, \fBconst char *\fR\fImode\fR);
25 The \fBfdopen()\fR function associates a stream with a file descriptor
29 The \fImode\fR argument is a character string having one of the following
37 \fBr\fR or \fBrb\fR Open a file for reading.
38 \fBw\fR or \fBwb\fR Open a file for writing.
39 \fBa\fR or \fBab\fR Open a file for writing at end of file.
40 \fBr+\fR, \fBrb+\fR or \fBr+b\fR T{
41 Open a file for update (reading and writing).
43 \fBw+\fR, \fBwb+\fR or \fBw+b\fR T{
44 Open a file for update (reading and writing).
46 \fBa+\fR, \fBab+\fR or \fBa+b\fR T{
47 Open a file for update (reading and writing) at end of file.
53 The meaning of these flags is exactly as specified for the \fBfopen\fR(3C)
54 function, except that modes beginning with \fIw\fR do not cause truncation of
55 the file. A trailing \fBF\fR character can also be included in the \fImode\fR
56 argument as described in \fBfopen\fR(3C) to enable extended FILE facility.
59 The mode of the stream must be allowed by the file access mode of the open
60 file. The file position indicator associated with the new stream is set to the
61 position indicated by the file offset associated with the file descriptor.
64 The \fBfdopen()\fR function preserves the offset maximum previously set for the
65 open file description corresponding to \fIfildes\fR.
68 The error and end-of-file indicators for the stream are cleared. The
69 \fBfdopen()\fR function may cause the \fBst_atime\fR field of the underlying
70 file to be marked for update.
73 If \fIfildes\fR refers to a shared memory object, the result of the
74 \fBfdopen()\fR function is unspecified.
78 Upon successful completion, \fBfdopen()\fR returns a pointer to a stream.
79 Otherwise, a null pointer is returned and \fBerrno\fR is set to indicate the
83 The \fBfdopen()\fR function may fail and not set \fBerrno\fR if there are no
84 free \fBstdio\fR streams.
88 The \fBfdopen()\fR function may fail if:
95 The \fIfildes\fR argument is not a valid file descriptor.
104 The \fImode\fR argument is not a valid mode.
113 {\fBFOPEN_MAX\fR} streams are currently open in the calling process.
115 {\fBSTREAM_MAX\fR} streams are currently open in the calling process.
124 There is insufficient space to allocate a buffer.
130 A process is allowed to have at least {\fBFOPEN_MAX\fR} \fBstdio\fR streams
131 open at a time. For 32-bit applications, however, the underlying ABIs formerly
132 required that no file descriptor used to access the file underlying a
133 \fBstdio\fR stream have a value greater than 255. To maintain binary
134 compatibility with earlier Solaris releases, this limit still constrains 32-bit
138 File descriptors are obtained from calls like \fBopen\fR(2), \fBdup\fR(2),
139 \fBcreat\fR(2) or \fBpipe\fR(2), which open files but do not return streams.
140 Streams are necessary input for almost all of the standard I/O library
145 See \fBattributes\fR(5) for descriptions of the following attributes:
153 ATTRIBUTE TYPE ATTRIBUTE VALUE
155 Interface Stability See below.
162 The \fBF\fR character in the \fImode\fR argument is Evolving. In all other
163 respects this function is Standard.
167 \fBcreat\fR(2), \fBdup\fR(2), \fBopen\fR(2), \fBpipe\fR(2), \fBfclose\fR(3C),
168 \fBfopen\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)