Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

Guardian Native C Library Calls (f) fclose(3)
NAME
fclose - Closes a stream
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdio.h>
int fclose (
FILE *stream);
PARAMETERS
stream Species the output or update stream.
DESCRIPTION
The fclose( ) function writes buffered data to the stream specied by the stream parameter, and
then closes the associated le. It is automatically called for all open les when the exit() func-
tion is invoked. Any unwritten buffered data for the stream is delivered to the host environment
to be written to the le; any unread buffered data is discarded. The stream is disassociated from
the le. If the associated buffer was automatically allocated, it is deallocated. Any further use of
the stream specied by the stream parameter causes undened behavior.
The fclose( ) function performs the close() function on the le descriptor associated with the
stream parameter. If the stream was writable and buffered data was not yet written to the le, it
marks the st_ctime and st_mtime elds of the underlying le for update. If the le is not already
at EOF, and is capable of seeking, the le pointer of the underlying open le descriptor is
adjusted so that the next operation on the open le descriptor deals with the byte after the last
one read from or written to the stream being closed.
RETURN VALUES
Upon successful completion, the fclose() function returns a value of 0 (zero). Otherwise, EOF is
returned, and errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the fclose() function sets errno to the value that
corresponds to the condition.
[EAGAIN] The O_NONBLOCK ag is set for the le descriptor underlying the stream
parameter and the process would be delayed in the write operation.
[EBADF] The le descriptor underlying the stream parameter is not valid.
[EFBIG] An attempt was made to write a le that exceeds the processs le size limit or
the maximum le size.
[EINTR] The fclose( ) function was interrupted by a signal that was caught.
[EIO] The TOSTOP tty local mode causes a background process to get a SIGTTOU
signal if it attempts to write to the controlling terminal. The SIGTTOU signal, if
it is not caught or ignored, will cause the process to block in a stopped state. A
process in an orphaned process group is not allowed to become stopped, since
there is no unprivileged process to unblock it. This condition only applies to
operations on stdio streams associated with ttys.
[EIO] is also associated with driver errors.
527192-005 Hewlett-Packard Company 23