Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
close(2) OSS System Calls Reference Manual
NAME
close - Closes a file descriptor
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
SYNOPSIS
#include <unistd.h>
int close(
int filedes);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the accept(),
creat(), dup( ), dup2( ), fcntl(), open(), pipe(), socket(),orsocketpair() func-
tion.
When the function is thread-aware, specifies an open file descriptor obtained
from a successful call to the creat(), creat64(), dup(), open(), open64(),
pipe( ), socket(),orsocketpair() function, or the thread-aware accept(),
dup2( ),orfcntl( ) function.
DESCRIPTION
The close() 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 fcntl( ) function are unlocked. This 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 fcntl( ) 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.
Use From a Threaded Application
If a thread calls the thread-aware close() to close a file that already has a file operation in pro-
gress by a different thread, the new thread is blocked until the prior file operation completes.
NOTES
To use the close() functionality in a threaded application that uses the Standard POSIX Threads
library, see spt_closez(2).
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the fol-
lowing tasks to make the function thread-aware in a multi-threaded application:
1−34 Hewlett-Packard Company 527186-023