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

close(2) OSS System Calls Reference Manual
NAME
close - Closes a le descriptor
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <unistd.h>
int close(
int filedes);
PARAMETERS
filedes Species an open le descriptor obtained from a successful call to the accept(),
creat(), dup( ), dup2( ), fcntl( ), open(), pipe( ), socket(),orsocketpair() func-
tion.
DESCRIPTION
The close() function closes the le descriptor specied by the filedes parameter.
All regions of the le 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 le
open by another le descriptor.
When the last le descriptor associated with an open le descriptor is closed:
The open le descriptor is freed.
The last modication time for the le is updated.
All locks created by fcntl() for the le are released.
If the link count of the le is 0 (zero), the space occupied by the le is freed, and the le
is no longer accessible.
If the le is a socket, the socket is destroyed.
If the le is a pipe or FIFO, any data remaining in the pipe or FIFO is discarded.
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.
ERRORS
If any of these conditions occur, the close() function sets errno to the corresponding value:
[EBADF] The filedes parameter is not a valid open le descriptor.
[EIO] An input or output error occurred. The device that the le is stored on might be
in the down state, or both processors that provide access to the device might
have failed.
[EISGUARDIAN]
The value used for the filedes parameter is appropriate only in the Guardian
environment.
For all other error conditions, errno is set to the appropriate Guardian le-
system error number. See the Guardian Procedure Errors and Messages
Manual for more information about a specic Guardian le-system error.
126 Hewlett-Packard Company 527186-005