Open System Services System Calls Reference Manual (G06.28+, H06.05+)
close(2) OSS System Calls Reference Manual
NAME
close - Closes a file 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 Specifies an open file 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 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.
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 file descriptor.
[EIO] An input or output error occurred. The device that the file 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 file-
system error number. See the Guardian Procedure Errors and Messages
Manual for more information about a specific Guardian file-system error.
1−32 Hewlett-Packard Company 527186-007