int close (int fildes);
The fildes argument is a file descriptor obtained from a creat, open, dup, fcntl, or pipe system call. The close system call closes the file descriptor indicated by fildes. All outstanding record locks owned by the process (on the file indicated by fildes) are removed.
If a STREAMS file is closed, and the calling process had previously registered to receive a SIGPOLL signal (see sigaction(S-osr5) and sigset(S-osr5)) for events associated with that file, the calling process is unregistered for events associated with the file. The last close for a stream causes the stream associated with fildes to be dismantled. If O_NONBLOCK is not set and there have been no signals posted for the stream, close waits up to 15 seconds, for each module and driver, for any output to drain before dismantling the stream. If the O_NONBLOCK flag is set or if there are any pending signals, close does not wait for output to drain and dismantles the stream immediately.
The named file is closed unless one or more of the following is true:
int fd;Note that all open files in a program are closed when a program terminates normally or when the exit function is called, so no explicit call to close is required.
if (argc >1) close(0);
X/Open Portability Guide, Issue 3, 1989
Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2) ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ;
and NIST FIPS 151-1 .