NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO
#include <unistd.h>int close(int fildes);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
MSDOSFS, NFS_CLIENT, UFS, POSIX_SOCKETS, POSIX_SHM
The fildes field contains a file descriptor obtained from an open(2POSIX), dup(2POSIX), accept(2POSIX), socket(2POSIX), or shm_open(2POSIX) system call. The close function closes the file descriptor indicated by fildes.
Upon successful completion, close returns 0; otherwise it returns -1 and sets errno to indicate one of the following error conditions.
When a process forks (see fork(2POSIX)), all descriptors for the new child process reference the same objects as they did in the parent before the fork. If a new process is then to be run using execve(2POSIX), the process would normally inherit these descriptors. Most of the descriptors can be rearranged with dup2(2POSIX) or deleted with the close()before the execve(2POSIX) is attempted, but if some of these descriptors will still be needed if the execve fails, it is necessary to arrange for them to be closed if the execve succeeds. For this reason, the call ``fcntl(d, F_SETFD, 1)'' is provided, which arranges that a descriptor will be closed after a successful execve; the call ``fcntl(d, F_SETFD, 0)'' restores the default, which is to not close the descriptor.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
MT-Level | Async-Signal-Safe |
accept(2POSIX), afexec(2K), dup(2POSIX), open(2POSIX), socket(2POSIX), shm_open(2POSIX), socketpair(2POSIX), pipe(2POSIX)
NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO