CLOSE(2,L) AIX Technical Reference CLOSE(2,L) ------------------------------------------------------------------------------- close, closex PURPOSE Closes the file associated with a file descriptor. SYNTAX int close (fildes) int fildes; int closex (fildes, ext) int fildes, ext; DESCRIPTION The close and closex system calls close the file associated with the file descriptor fildes. The fildes parameter is a file descriptor obtained from a creat, open, dup, fcntl, or pipe system call. The ext parameter provides communication with character device drivers that require additional information or return additional status. Each driver interprets the ext parameter in a device-dependent way, either as a value or as a pointer to a communication area. Drivers must apply reasonable defaults when the ext parameter is 0. If the file is open in O_DEFERC mode, changes are made permanent by using the commit mechanism at some point after the file is closed. The commit operation implicit in close is done asynchronously, and consequently, problems such as I/O errors and losses of file servers may go unreported. In these situations, the content of the file is rolled back to the previously committed version (see "fabort"). Programs which desire synchronous error reporting and a guarantee that the changes to the file have been made permanent should use the fcommit system call explicitly before using close. If the file is open for writing using more than one file descriptor (by this process or in conjunction with other processes) the commit semantics described above apply only if the O_DEFERC flag is set on for all opens. Any other open or creat system call may cause the file contents to be permanently updated periodically (see "sync"). All locks held on the file by the calling process, whether they are applied using this file descriptor or another one, are released when the file is closed (see "fcntl, flock, lockf"). If the fildes parameter is associated with a mapped file and if no other process has attached this mapped file, it is unmapped. Processed November 7, 1990 CLOSE(2,L) 1 CLOSE(2,L) AIX Technical Reference CLOSE(2,L) RETURN VALUE Upon successful completion, a value of 0 is returned. If the close system call fails, a value of -1 is returned, and errno is set to indicate the error. ERROR CONDITIONS The close and closex system calls fail if the following is true: EBADF The fildes parameter is not a valid open file descriptor. RELATED INFORMATION In this book: "open, openx, creat," "dup," "exec: execl, execv, execle, execve, execlp, execvp," "fcntl, flock, lockf," "pipe," and "socket." Processed November 7, 1990 CLOSE(2,L) 2