Open System Services System Calls Reference Manual (G06.28+)

spt_fclosex(2) OSS System Calls Reference Manual
NAME
spt_fclosex - Closes a stream (thread-aware version)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <stdio.h>]
#include <spthread.h>
int spt_fclosex (
FILE *stream
);
PARAMETERS
stream Species the output or update stream.
DESCRIPTION
The spt_fclosex() function is the thread-aware version of the fclose() function.
The spt_fclosex() 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()
function is invoked. Any unwritten buffered data for the stream is delivered to the host environ-
ment 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 spt_fclosex() 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 end-of-le (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.
NOTES
The macro to map fclose( ) to spt_fclosex() is available in C applications when
SPT_THREAD_AWARE_NONBLOCK has been dened in the following manner before
including spthread.h:
#dene SPT_THREAD_AWARE_NONBLOCK
The alias to link fclose( ) to spt_fclosex() is available in C++ applications when
SPT_THREAD_AWARE_PRAGMA_NONBLOCK has been dened in the following manner
before including spthread.h:
#dene SPT_THREAD_AWARE_PRAGMA_NONBLOCK
RETURN VALUES
Upon successful completion, the spt_fclosex( ) function returns a value of 0 (zero). Otherwise,
EOF is returned, and errno is set to indicate the error.
If the le descriptor underlying stream becomes invalid (is closed by another thread), EOF is
returned with an errno value of [EBADF]. If a signal is received via the pthread_kill() function
and is not blocked, ignored, or handled, EOF is returned with an errno value of [EINTR].
7110 Hewlett-Packard Company 527186-005