245 lines
9.6 KiB
HTML
245 lines
9.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>fflush</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="fflush"></a> <a name="tag_03_160"></a><!-- fflush -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_160_01"></a>NAME</h4>
|
|
|
|
<blockquote>fflush - flush a stream</blockquote>
|
|
|
|
<h4><a name="tag_03_160_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>#include <<a href="../basedefs/stdio.h.html">stdio.h</a>><br>
|
|
<br>
|
|
int fflush(FILE *</tt><i>stream</i><tt>);<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
|
|
border="0"> The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the
|
|
requirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers to
|
|
the ISO C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div>
|
|
|
|
<p>If <i>stream</i> points to an output stream or an update stream in which the most recent operation was not input,
|
|
<i>fflush</i>() shall cause any unwritten data for that stream to be written to the file, <sup>[<a href=
|
|
"javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> and the
|
|
<i>st_ctime</i> and <i>st_mtime</i> fields of the underlying file shall be marked for update. <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></p>
|
|
|
|
<p>If <i>stream</i> is a null pointer, <i>fflush</i>() shall perform this flushing action on all streams for which the behavior is
|
|
defined above.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, <i>fflush</i>() shall return 0; otherwise, it shall set the error indicator for the stream, return
|
|
EOF, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
and set <i>errno</i> to indicate the error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>fflush</i>() function shall fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EAGAIN]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The O_NONBLOCK flag is set for the file descriptor underlying <i>stream</i> and the process would be delayed in the write
|
|
operation. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
|
|
<dt>[EBADF]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The file descriptor underlying <i>stream</i> is not valid. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
|
|
<dt>[EFBIG]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> An
|
|
attempt was made to write a file that exceeds the maximum file size. <img src="../images/opt-end.gif" alt="[Option End]" border=
|
|
"0"></dd>
|
|
|
|
<dt>[EFBIG]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
An attempt was made to write a file that exceeds the process' file size limit. <img src="../images/opt-end.gif" alt="[Option End]"
|
|
border="0"></dd>
|
|
|
|
<dt>[EFBIG]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The file is a regular file and an attempt was made to write at or beyond the offset maximum associated with the corresponding
|
|
stream. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
|
|
<dt>[EINTR]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The <i>fflush</i>() function was interrupted by a signal. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
|
|
<dt>[EIO]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The process is a member of a background process group attempting to write to its controlling terminal, TOSTOP is set, the process
|
|
is neither ignoring nor blocking SIGTTOU, and the process group of the process is orphaned. This error may also be returned under
|
|
implementation-defined conditions. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
|
|
<dt>[ENOSPC]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
There was no free space remaining on the device containing the file. <img src="../images/opt-end.gif" alt="[Option End]" border=
|
|
"0"></dd>
|
|
|
|
<dt>[EPIPE]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> An
|
|
attempt is made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal shall also be sent to the
|
|
thread. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
</dl>
|
|
|
|
<p>The <i>fflush</i>() function may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[ENXIO]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> A
|
|
request was made of a nonexistent device, or the request was outside the capabilities of the device. <img src=
|
|
"../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_160_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<h5><a name="tag_03_160_06_01"></a>Sending Prompts to Standard Output</h5>
|
|
|
|
<p>The following example uses <a href="../functions/printf.html"><i>printf</i>()</a> calls to print a series of prompts for
|
|
information the user must enter from standard input. The <i>fflush</i>() calls force the output to standard output. The
|
|
<i>fflush</i>() function is used because standard output is usually buffered and the prompt may not immediately be printed on the
|
|
output or terminal. The <a href="../functions/gets.html"><i>gets</i>()</a> calls read strings from standard input and place the
|
|
results in variables, for use later in the program.</p>
|
|
|
|
<pre>
|
|
<tt>#include <stdio.h>
|
|
...
|
|
char user[100];
|
|
char oldpasswd[100];
|
|
char newpasswd[100];
|
|
...
|
|
printf("User name: ");
|
|
fflush(stdout);
|
|
gets(user);
|
|
<br>
|
|
printf("Old password: ");
|
|
fflush(stdout);
|
|
gets(oldpasswd);
|
|
<br>
|
|
printf("New password: ");
|
|
fflush(stdout);
|
|
gets(newpasswd);
|
|
...
|
|
</tt>
|
|
</pre>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>Data buffered by the system may make determining the validity of the position of the current file descriptor impractical. Thus,
|
|
enforcing the repositioning of the file descriptor after <i>fflush</i>() on streams open for <a href=
|
|
"../functions/read.html"><i>read</i>()</a> is not mandated by IEEE Std 1003.1-2001.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="getrlimit.html"><i>getrlimit</i>()</a> , <a href="ulimit.html"><i>ulimit</i>()</a> , the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/stdio.h.html"><i><stdio.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 1. Derived from Issue 1 of the SVID.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Large File Summit extensions are added.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_160_13"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>Extensions beyond the ISO C standard are marked.</p>
|
|
|
|
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The [EFBIG] error is added as part of the large file support extensions.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The [ENXIO] optional error condition is added.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>The RETURN VALUE section is updated to note that the error indicator shall be set for the stream. This is for alignment with the
|
|
ISO/IEC 9899:1999 standard.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|