1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
1 |
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved |
2
by Francesco Paolo Lovergine
* Alligned to linux main manpages edition. |
2 |
.TH "FFLUSH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" |
1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
3 |
.\" fflush |
4 |
.SH NAME |
|
5 |
fflush \- flush a stream
|
|
6 |
.SH SYNOPSIS |
|
7 |
.LP
|
|
8 |
\fB#include <stdio.h>
|
|
9 |
.br
|
|
10 |
.sp
|
|
11 |
int fflush(FILE *\fP\fIstream\fP\fB); |
|
12 |
.br
|
|
13 |
\fP
|
|
14 |
.SH DESCRIPTION |
|
15 |
.LP
|
|
16 |
If \fIstream\fP points to an output stream or an update stream in |
|
17 |
which the most recent operation was not input, |
|
18 |
\fIfflush\fP() shall cause any unwritten data for that stream to be |
|
19 |
written to the file, \ and the
|
|
20 |
\fIst_ctime\fP and \fIst_mtime\fP fields of the underlying file shall |
|
21 |
be marked for update. |
|
22 |
.LP
|
|
23 |
If \fIstream\fP is a null pointer, \fIfflush\fP() shall perform this |
|
24 |
flushing action on all streams for which the behavior is |
|
25 |
defined above. |
|
26 |
.SH RETURN VALUE |
|
27 |
.LP
|
|
28 |
Upon successful completion, \fIfflush\fP() shall return 0; otherwise, |
|
29 |
it shall set the error indicator for the stream, return |
|
30 |
EOF, |
|
31 |
\ and set \fIerrno\fP to indicate the error. |
|
32 |
.SH ERRORS |
|
33 |
.LP
|
|
34 |
The \fIfflush\fP() function shall fail if: |
|
35 |
.TP 7 |
|
36 |
.B EAGAIN |
|
37 |
The O_NONBLOCK flag is set for the file descriptor underlying \fIstream\fP |
|
38 |
and the process would be delayed in the write |
|
39 |
operation. |
|
40 |
.TP 7 |
|
41 |
.B EBADF |
|
42 |
The file descriptor underlying \fIstream\fP is not valid. |
|
43 |
.TP 7 |
|
44 |
.B EFBIG |
|
45 |
An |
|
46 |
attempt was made to write a file that exceeds the maximum file size. |
|
47 |
.TP 7 |
|
48 |
.B EFBIG |
|
49 |
An attempt was made to write a file that exceeds the process' file |
|
50 |
size limit. |
|
51 |
.TP 7 |
|
52 |
.B EFBIG |
|
53 |
The file is a regular file and an attempt was made to write at or |
|
54 |
beyond the offset maximum associated with the corresponding |
|
55 |
stream. |
|
56 |
.TP 7 |
|
57 |
.B EINTR |
|
58 |
The \fIfflush\fP() function was interrupted by a signal. |
|
59 |
.TP 7 |
|
60 |
.B EIO |
|
61 |
The process is a member of a background process group attempting to |
|
62 |
write to its controlling terminal, TOSTOP is set, the process |
|
63 |
is neither ignoring nor blocking SIGTTOU, and the process group of |
|
64 |
the process is orphaned. This error may also be returned under |
|
65 |
implementation-defined conditions. |
|
66 |
.TP 7 |
|
67 |
.B ENOSPC |
|
68 |
There was no free space remaining on the device containing the file. |
|
69 |
.TP 7 |
|
70 |
.B EPIPE |
|
71 |
An |
|
72 |
attempt is made to write to a pipe or FIFO that is not open for reading |
|
73 |
by any process. A SIGPIPE signal shall also be sent to the |
|
74 |
thread. |
|
75 |
.sp
|
|
76 |
.LP
|
|
77 |
The \fIfflush\fP() function may fail if: |
|
78 |
.TP 7 |
|
79 |
.B ENXIO |
|
80 |
A |
|
81 |
request was made of a nonexistent device, or the request was outside |
|
82 |
the capabilities of the device. |
|
83 |
.sp
|
|
84 |
.LP
|
|
85 |
\fIThe following sections are informative.\fP |
|
86 |
.SH EXAMPLES |
|
87 |
.SS Sending Prompts to Standard Output |
|
88 |
.LP
|
|
89 |
The following example uses \fIprintf\fP() calls to print a series |
|
90 |
of prompts for |
|
91 |
information the user must enter from standard input. The \fIfflush\fP() |
|
92 |
calls force the output to standard output. The |
|
93 |
\fIfflush\fP() function is used because standard output is usually |
|
94 |
buffered and the prompt may not immediately be printed on the |
|
95 |
output or terminal. The \fIgets\fP() calls read strings from standard |
|
96 |
input and place the |
|
97 |
results in variables, for use later in the program. |
|
98 |
.sp
|
|
99 |
.RS
|
|
100 |
.nf
|
|
101 |
||
102 |
\fB#include <stdio.h>
|
|
103 |
\&...
|
|
104 |
char user[100]; |
|
105 |
char oldpasswd[100]; |
|
106 |
char newpasswd[100]; |
|
107 |
\&...
|
|
108 |
printf("User name: "); |
|
109 |
fflush(stdout); |
|
110 |
gets(user); |
|
111 |
.sp
|
|
112 |
||
113 |
printf("Old password: "); |
|
114 |
fflush(stdout); |
|
115 |
gets(oldpasswd); |
|
116 |
.sp
|
|
117 |
||
118 |
printf("New password: "); |
|
119 |
fflush(stdout); |
|
120 |
gets(newpasswd); |
|
121 |
\&...
|
|
122 |
\fP
|
|
123 |
.fi
|
|
124 |
.RE
|
|
125 |
.SH APPLICATION USAGE |
|
126 |
.LP
|
|
127 |
None. |
|
128 |
.SH RATIONALE |
|
129 |
.LP
|
|
130 |
Data buffered by the system may make determining the validity of the |
|
131 |
position of the current file descriptor impractical. Thus, |
|
132 |
enforcing the repositioning of the file descriptor after \fIfflush\fP() |
|
133 |
on streams open for \fIread\fP() is not mandated by IEEE\ Std\ 1003.1-2001. |
|
134 |
.SH FUTURE DIRECTIONS |
|
135 |
.LP
|
|
136 |
None. |
|
137 |
.SH SEE ALSO |
|
138 |
.LP
|
|
139 |
\fIgetrlimit\fP() , \fIulimit\fP() , the Base Definitions volume of |
|
140 |
IEEE\ Std\ 1003.1-2001, \fI<stdio.h>\fP |
|
141 |
.SH COPYRIGHT |
|
142 |
Portions of this text are reprinted and reproduced in electronic form |
|
143 |
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology |
|
144 |
-- Portable Operating System Interface (POSIX), The Open Group Base |
|
145 |
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of |
|
146 |
Electrical and Electronics Engineers, Inc and The Open Group. In the |
|
147 |
event of any discrepancy between this version and the original IEEE and |
|
148 |
The Open Group Standard, the original IEEE and The Open Group Standard |
|
149 |
is the referee document. The original Standard can be obtained online at |
|
150 |
http://www.opengroup.org/unix/online.html . |