icon Top 9 categories map      RocketAware > man pages >

close(2)

Tips: Browse or Search all pages for efficient awareness of more than 6000 of the most popular reusable and open source applications, functions, libraries, and FAQs.


The "RKT couplings" below include links to source code, updates, additional information, advice, FAQs, and overviews.


Home

Search all pages


Subjects

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Math
Integer, Floating point, Matrix, Statistics, Boolean, ...

Processing
Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Communications
Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...

    

RocketLink!--> Man page versions: OpenBSD FreeBSD NetBSD RedHat Solaris Others



CLOSE(2)                  OpenBSD Programmer's Manual                 CLOSE(2)

NAME
     close - delete a descriptor



SYNOPSIS
     #include <unistd.h>

     int
     close(int d);

DESCRIPTION
     The close() call deletes a descriptor from the per-process object refer-
     ence table.  If this is the last reference to the underlying object, the
     object will be deactivated.  For example, on the last close of a file the
     current seek pointer associated with the file is lost; on the last close
     of a socket(2) associated naming information and queued data are discard-
     ed; on the last close of a file holding an advisory lock the lock is re-
     leased. However, the semantics of System V and IEEE Std1003.1-1988
     (``POSIX'') dictate that all fcntl(2) advisory record locks associated
     with a file for a given process are removed when any file descriptor for
     that file is closed by that process (see further flock(2)).

     When a process exits, all associated file descriptors are freed, but
     since there is a limit on active descriptors per processes, the close()
     function call is useful when a large quantity of file descriptors are be-
     ing handled.

     When a process forks (see fork(2)),  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(2),  the process
     would normally inherit these descriptors.  Most of the descriptors can be
     rearranged with dup2(2) or deleted with close() before the execve(2) 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 ex-
     ecve succeeds.  For this reason, the call ``fcntl(d, F_SETFD, 1)'' is
     provided, which arranges that a descriptor will be closed after a suc-
     cessful execve; the call ``fcntl(d, F_SETFD, 0)'' restores the default,
     which is to not close the descriptor.

RETURN VALUES
     Upon successful completion, a value of 0 is returned.  Otherwise, a value
     of -1 is returned and the global integer variable errno is set to indi-
     cate the error.

ERRORS
     close() will fail if:

     [EBADF]       D is not an active descriptor.

     [EINTR]       An interrupt was received.

SEE ALSO
     accept(2),  execve(2),  fcntl(2),  flock(2),  open(2),  pipe(2),
     socket(2),  socketpair(2)

STANDARDS
     close() conforms to IEEE Std1003.1-1988 (``POSIX'').

OpenBSD 2.6                     April 19, 1994                               1

Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.



(Corrections, notes, and links courtesy of RocketAware.com)


[Detailed Topics]


[Overview Topics]

Up to: Low level file and device operations - " Unbuffered " access of files and devices. (ioctl, fcntl, /dev, et al)


RocketLink!--> Man page versions: OpenBSD FreeBSD NetBSD RedHat Solaris Others






Rapid-Links: Search | About | Comments | Submit Path: RocketAware > man pages > close.2/
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments