fildes is a file descriptor obtained from a creat() , open() , dup() , fcntl or pipe() system call.
close() closes the file descriptor indicated by fildes. All existing record locks owned by the process on the file specified with fildes are removed. If close() is interrupted by a signal that is to be caught, it will return -1 with errno set to
EINTR, and the state of fildes is unspecified. When all file descriptors associated with a pipe or FIFO special file are closed, any data remaining in the pipe or FIFO will be discarded. When all file descriptors associated with a file description have been closed, the file description will be freed. If the link count of the file is 0, when all file descriptors associated with the file are closed, the space occupied by the file will be freed and the file will no longer be accessible. Extension If a stream-based file is closed and the calling process was previously registered to receive a SIGPOLL signal (see signal() and sigset() ) for events associated with that stream, the calling process will be unregistered for events associated with the stream. The last
close() for a stream causes the stream associated with fildes to be dismantled. If
O_NDELAY and O_NONBLOCK are not set and there have been no signals posted for the stream, close() waits for up to 15 seconds for each module and driver for any queued output to drain before dismantling the stream. If O_NDELAY or O_NONBLOCK is set, or if there are any pending signals, close() does not wait for the output to drain and dismantles the stream immediately. (End) |