fclose()

NAME

fclose() - close a stream

SYNOPSIS

#include <stdio.h>

int fclose (FILE *stream)

DESCRIPTION

The fclose(3) function dissociates the named stream from its underlying file or set of functions. If the stream was being used for output, any buffered data is written first, using fflush(3).

RETURN VALUES

Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the error. In either case no further access to the stream is possible.

ERRORS

[EAGAIN]
The O_NONBLOCK flag is set for the file and the process would be delayed in the flush (write) operation.
[EBADF]
The argument stream is not an open stream.
[EFBIG]
Flushing output would result in a file that exceeds the maximum file size.
[EINTR}
A signal interrupted the close operation.
[EIO]
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-dependent conditions.
[ENOSPC]
There is no space on the device to write pending output.
[EPIPE]
stream is actually a pipe (or FIFO) that is not open for reading by any process.

SEE ALSO

close(2)

fflush(3)

fopen(3)

setbuf(3)