[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

fclose or fflush Subroutine

Purpose

Closes or flushes a stream.

Library

Standard C Library (libc.a)

Syntax

#include <stdio.h>
int fclose (Stream)
FILE *Stream;
int fflush (Stream)
FILE *Stream;

Description

The fclose subroutine writes buffered data to the stream specified by the Stream parameter, and then closes the stream. The fclose subroutine is automatically called for all open files when the exit subroutine is invoked.

The fflush subroutine writes any buffered data for the stream specified by the Stream parameter and leaves the stream open. The fflush subroutine marks the st_ctime and st_mtime fields of the underlying file for update.

If the Stream parameter is a null pointer, the fflush subroutine performs this flushing action on all streams for which the behavior is defined.

Parameters

Stream Specifies the output stream.

Return Values

Upon successful completion, the fclose and fflush subroutines return a value of 0. Otherwise, a value of EOF is returned.

Error Codes

If the fclose and fflush subroutines are unsuccessful, the following errors are returned through the errno global variable:

EAGAIN The O_NONBLOCK flag is set for the file descriptor underlying the Stream parameter 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' file size limit or the maximum file size. See the ulimit subroutine.
EFBIG The file is a regular file and an attempt was made to write at or beyond the offset maximum associated with the corresponding stream.
EINTR The fflush subroutine was interrupted by a signal.
EIO The process is a member of a background process group attempting to write to its controlling terminal, the TOSTOP signal is set, the process is neither ignoring nor blocking the SIGTTOU signal and the process group of the process is orphaned. This error may also be returned under implementation-dependent conditions.
ENOSPC No free space remained on the device containing the file.
EPIPE An attempt is made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal is sent to the process.
ENXIO A request was made of a non-existent device, or the request was outside the capabilities of the device

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The close subroutine, exit, atexit, or _exit subroutine, fopen, freopen, or fdopen subroutine, setbuf, setvbuf, setbuffer, or setlinebuf subroutine.

Input and Output Handling Programmer's Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]