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).
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.
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.