Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fflush(3S) — HP-UX 9.10

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(2)

exit(2)

lseek(2)

write(2)

fopen(3S)

setbuf(3S)

fclose(3S)

NAME

fclose(), fflush() − close or flush a stream

SYNOPSIS

#include <stdio.h>

int fclose(FILE *stream);

int fflush(FILE *stream);

DESCRIPTION

fclose() causes any buffered data for the named stream to be written out, and the stream to be closed.  Buffers allocated by the standard input/output system may be freed. 

fclose() is performed automatically for all open files upon calling exit(2).

If stream points to an output stream or an update stream in which the most recent operation was output, fflush() causes any buffered data for the stream to be written to that file; otherwise any buffered data is discarded.  The stream remains open. 

If stream is a null pointer, fflush() performs this flushing action on all currently open streams. 

RETURN VALUE

Upon successful completion, fclose() and fflush() return 0.  Otherwise, they return EOF and set errno to indicate the error. 

ERRORS

fclose() and fflush() fail if:

[EAGAIN] The O_NONBLOCK flag is set for the file descriptor underlying stream and the process would be delayed in the write operation. 

[EBADF] The file descriptor underlying stream is not valid. 

[EFBIG] An attempt was made to write a file that exceeds the process’s file size limit or the maximum file size (see ulimit(2)).

[EINTR] fclose() or fflush() was interrupted by a signal. 

[EIO] The process is in a background process group and is attempting to write to its controlling terminal, TOSTOP is set, the process is neither ignoring nor blocking the SIGTTOU signal, and the process group of the process is orphaned. 

[ENOSPC] There was no free space remaining on the device containing the file. 

[EPIPE] An attempt was made to write to a pipe that is not open for reading by any process.  A SIGPIPE signal is also sent to the process. 

Additional errno values may be set by the underlying write(), lseek(), and close() functions (see write(2), lseek(2) and close(2)).

SEE ALSO

close(2), exit(2), lseek(2), write(2), fopen(3S), setbuf(3S). 

STANDARDS CONFORMANCE

fclose(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

fflush(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Hewlett-Packard Company  —  HP-UX Release 9.10: April 1995

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026