HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

close

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Closes a file.

Syntax

   #include <unistd.h> 

   int close (int fildes);

Parameters

fildes

An open file descriptor.

Return Values

0

Success. The file is closed.

-1

An error occurred. The file is not closed, and errno is set to indicate the error condition.

Description

The close() function closes the file specified by fildes. Upon the close, all record locks held by the calling process on the file associated with fildes are removed.

When all file descriptors associated with an open file description have been closed, the open file description is freed and is no longer accessible.

If the link count of the file is zero upon closing, when all open file descriptors associated with the file are closed, the file is purged from the system.

The close() function updates the following file time fields to the current time:

  • All time fields that have been previously marked for update. All update marks are removed.

  • The st_atime time field.

  • The st_mtime time field only if the file was opened O_WRONLY or O_RDWR.

Implementation Considerations

Refer to the ESYSERR error description below.

Signals generated for the calling process during the execution of close() are deferred from delivery until the completion of close().

Errors

If an error occurs, errno is set to one of the following values:

EBADFCAUSEThe fildes parameter is not a valid open file descriptor.
 ACTIONCheck to see if fildes has been altered or is not initialized.
ESYSERRCAUSEAn operating system error has occurred that does not map directly to any of the above errors.
 ACTIONExamine the MPE/iX error stack for the type of system error.

See Also

creat(), dup(), execl(), execv(), fork(), open(), unlink(), POSIX.1 (Section 6.3.1)

Feedback to webmaster