COHERENT manpages

This page displays the COHERENT manpage for close() [Close a file].

List of available manpages
Index


close() -- System Call (libc)

Close a file
#include <unistd.h>
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

creat(),
libc,
open(),
unistd.h
ANSI Standard, §4.9.3
POSIX Standard, §6.3.1

Diagnostics

close() returns -1 if an error  occurs, such as its being handed a bad file
descriptor; otherwise, it returns zero.