close() COHERENT System Call close() Close a file int close(fd) int fd; close closes the file identified by the file descriptor fd, which was returned by creat, dup, open, or pipe. close also frees the associated file descriptor. Because each program can have only a limited number of files open at any given time, programs that process many files should close files whenever possible. The function exit automatically calls fclose for all open files; however, the system call _exit does not. ***** Example ***** For an example of this function, see the entry for open. ***** See Also ***** COHERENT system calls, creat(), open() ***** Diagnostics ***** close returns -1 if an error occurs, such as its being handed a bad file descriptor; otherwise, it returns zero. COHERENT Lexicon Page 1