Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (s and S) spt_closez(2)
NAME
spt_closez - Initiates close( ) function for thread-aware functions
LIBRARY
H-series and J series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int spt_closez(
int filedes);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the acceptx(),
creat(), dup( ), dup2( ), spt_dup2x(), spt_fcntlz( ), open(), open64(), pipe(),
socket(),orsocketpair() function.
DESCRIPTION
Use spt_closez() instead of close() or spt_closex() to ensure proper operation of the various
thread-aware I/O functions if spt_*z() function calls are used.
The spt_closez() function closes the file descriptor specified by the filedes parameter.
All regions of the file specified by the filedes parameter that this process has locked with the
spt_fcntlz() function are unlocked by the spt_closez() function. This behavior occurs even if
the process still has the file open using a different file descriptior.
When the last file descriptor associated with an open file descriptor is closed:
The open file descriptor is freed.
The last modification time for the file is updated.
If the link count of the file is 0 (zero), the space occupied by the file is freed, and the file
is no longer accessible.
If the file is a socket, the socket is destroyed.
If the file is a pipe or FIFO, any data remaining in the pipe or FIFO is discarded.
NOTES
For file descriptors for non-regular files, the spt_closez() function behaves exactly the same as
spt_closex(). For file descriptors for regular files, spt_closez() first flushes dirty cache blocks by
calling spt_fsyncz(), which is a thread aware function that blocks only the calling thread during
its operation. If a thread calls spt_closez() to close a file that already has a file operation in pro-
gress by a different thread, this thread is blocked until the prior file operation is complete.
This function serializes file operations on an open file. If a thread calls spt_closez() to access a
file that already has a file operation in progress by a different thread, this thread is blocked until
the prior file operation is complete.
For C applications, a macro to map close() to spt_closez() is available when you use the #define
SPT_THREAD_AWARE_XNONBLOCK preprocessor directive before including spthread.h
or when you use an equivalent compiler command option to compile the application.
For C++ applications, an alias to map close() to spt_closez() is available when you use the
#define SPT_THREAD_AWARE_PRAGMA_XNONBLOCK preprocessor directive before
including spthread.h or when you use an equivalent compiler command option to compile the
application.
To use this function in a threaded application that uses the Standard POSIX Threads library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the
527186-023 Hewlett-Packard Company 7143