home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / man / cat2 / close.0 < prev    next >
Text File  |  1993-12-07  |  3KB  |  67 lines

  1.  
  2. CLOSE(2)                   UNIX Programmer's Manual                   CLOSE(2)
  3.  
  4. NNAAMMEE
  5.      cclloossee - delete a descriptor
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<uunniissttdd..hh>>
  9.  
  10.      _i_n_t
  11.      cclloossee(_i_n_t _d)
  12.  
  13. DDEESSCCRRIIPPTTIIOONN
  14.      The cclloossee() call deletes a descriptor from the per­process object refer­
  15.      ence table.  If this is the last reference to the underlying object, the
  16.      object will be deactivated.  For example, on the last close of a file the
  17.      current _s_e_e_k pointer associated with the file is lost; on the last close
  18.      of a socket(2) associated naming information and queued data are discard­
  19.      ed; on the last close of a file holding an advisory lock the lock is re­
  20.      leased (see further flock(2)).
  21.  
  22.      When a process exits, all associated file descriptors are freed, but
  23.      since there is a limit on active descriptors per processes, the cclloossee()
  24.      function call is useful when a large quanitity of file descriptors are
  25.      being handled.
  26.  
  27.      When a process forks (see fork(2)),  all descriptors for the new child
  28.      process reference the same objects as they did in the parent before the
  29.      fork.  If a new process is then to be run using execve(2),  the process
  30.      would normally inherit these descriptors.  Most of the descriptors can be
  31.      rearranged with dup2(2) or deleted with cclloossee() before the execve is at­
  32.      tempted, but if some of these descriptors will still be needed if the ex­
  33.      ecve fails, it is necessary to arrange for them to be closed if the ex­
  34.      ecve succeeds.  For this reason, the call ``fcntl(d, F_SETFD, 1)'' is
  35.      provided, which arranges that a descriptor will be closed after a suc­
  36.      cessful execve; the call ``fcntl(d, F_SETFD, 0)'' restores the default,
  37.      which is to not close the descriptor.
  38.  
  39. RREETTUURRNN VVAALLUUEESS
  40.      Upon successful completion, a value of 0 is returned.  Otherwise, a value
  41.      of ­1 is returned and the global integer variable _e_r_r_n_o is set to indi­
  42.      cate the error.
  43.  
  44. EERRRROORRSS
  45.      CClloossee() will fail if:
  46.  
  47.      [EBADF]       _D is not an active descriptor.
  48.  
  49.      [EINTR]       An interupt was received.
  50.  
  51. SSEEEE AALLSSOO
  52.      accept(2),  flock(2),  open(2),  pipe(2),  socket(2),  socketpair(2),
  53.      execve(2),  fcntl(2)
  54.  
  55. SSTTAANNDDAARRDDSS
  56.      CClloossee() conforms to IEEE Std 1003.1­1988 (``POSIX'').
  57.  
  58. 4th Berkeley Distribution       March 10, 1991                               1
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.