📄 fdopen.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>fdopen</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_004_182"> </a>NAME</h4><blockquote>fdopen - associate a stream with a file descriptor</blockquote><h4><a name = "tag_000_004_183"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="stdio.h.html">stdio.h</a>>FILE *fdopen(int <i>fildes</i>, const char *<i>mode</i>);</code></pre></blockquote><h4><a name = "tag_000_004_184"> </a>DESCRIPTION</h4><blockquote>The<i>fdopen()</i>function associates a stream with a file descriptor.<p>The<i>mode</i>argument is a character string having one of the following values:<dl compact><dt>r or rb <dd>Open a file for reading.<dt>w or wb <dd>Open a file for writing.<dt>a or ab <dd>Open a file for writing at end of file.<dt>r+ or rb+ or r+b <dd>Open a file for update (reading and writing).<dt>w+ or wb+ or w+b <dd>Open a file for update (reading and writing).<dt>a+ or ab+ or a+b <dd>Open a file for update (reading and writing) at end of file.</dl><p>The meaning of these flags is exactly as specified in<i><a href="fopen.html">fopen()</a></i>,except that modes beginning with <b>w</b> do not causetruncation of the file.<p>Additional values for the<i>mode</i>argument may be supported by an implementation.<p>The mode of the stream must be allowed by the file access mode ofthe open file.The file position indicator associated with the new stream is setto the position indicated by the file offset associated with thefile descriptor.<p>The error and end-of-file indicators for the stream are cleared.The<i>fdopen()</i>function may cause the<i>st_atime</i>field of the underlying file to be marked for update.<p>If<i>fildes</i>refers to a shared memory object, the result of the<i>fdopen()</i>function is unspecified.<p>The<i>fdopen()</i>function will preserve the offset maximum previously set for the openfile description corresponding to<i>fildes</i>.</blockquote><h4><a name = "tag_000_004_185"> </a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>fdopen()</i>returns a pointer to a stream.Otherwise, a null pointer is returned and<i>errno</i>is set to indicate the error.</blockquote><h4><a name = "tag_000_004_186"> </a>ERRORS</h4><blockquote>The<i>fdopen()</i>function may fail if:<dl compact><dt>[EBADF]<dd>The<i>fildes</i>argumentis not a valid file descriptor.<dt>[EINVAL]<dd>The <i>mode</i> argument is not a valid mode.<dt>[EMFILE]<dd>{FOPEN_MAX} streams are currently open in the calling process.<dt>[EMFILE]<dd>{STREAM_MAX} streams are currently open in the calling process.<dt>[ENOMEM]<dd>Insufficient space to allocate a buffer.</dl></blockquote><h4><a name = "tag_000_004_187"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_004_188"> </a>APPLICATION USAGE</h4><blockquote>File descriptors are obtained from calls like<i><a href="open.html">open()</a></i>,<i><a href="dup.html">dup()</a></i>,<i><a href="creat.html">creat()</a></i>or<i><a href="pipe.html">pipe()</a></i>,which open files but do not return streams.</blockquote><h4><a name = "tag_000_004_189"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_004_190"> </a>SEE ALSO</h4><blockquote><i><a href="fclose.html">fclose()</a></i>,<i><a href="fopen.html">fopen()</a></i>,<i><a href="open.html">open()</a></i>,<i><a href="stdio.h.html"><stdio.h></a></i>,<a href="stdio.html">Standard I/O Streans</a>.<br></blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -