Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) spt_closex(2)
NAME
spt_closex - Closes a file descriptor (thread-aware version)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <unistd.h>]
#include <spthread.h>
int spt_closex(
int filedes
);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the
spt_acceptx(), creat(), dup(), spt_dup2x(), spt_fcntlx(), open(), pipe(),
socket(),orsocketpair() function.
DESCRIPTION
The spt_closex() function is a thread-aware version of the close() function. Use spt_closex()
instead of close() to ensure proper operation of the various thread-aware input/output functions.
The spt_closex() function closes the file descriptor specified by the filedes parameter.
All regions of the file associated with the filedes parameter that this process has previously
locked with the spt_fcntlx() function are unlocked. This behavior occurs even if the process still
has the file open by another file descriptor.
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.
• All locks created by spt_fcntlx() for the file are released.
• 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 C applications, a macro to map close() to spt_closex() is available when you use the #define
SPT_THREAD_AWARE_NONBLOCK 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_closex() is available when you use the
#define SPT_THREAD_AWARE_PRAGMA_NONBLOCK preprocessor directive before
including spthread.h or when you use an equivalent compiler command option to compile the
application.
RETURN VALUES
Upon successful completion, the value 0 (zero) is returned. Otherwise, the value -1 is returned,
and errno is set to indicate the error.
527186-023 Hewlett-Packard Company 7−141