home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / ixemul-39.47-env-bin.lha / man / cat2 / dup.0 < prev    next >
Text File  |  1993-12-07  |  2KB  |  67 lines

  1.  
  2. DUP(2)                     UNIX Programmer's Manual                     DUP(2)
  3.  
  4. NNAAMMEE
  5.      dduupp, dduupp22 - duplicate an existing file descriptor
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<uunniissttdd..hh>>
  9.  
  10.      _i_n_t
  11.      dduupp(_i_n_t _o_l_d_d)
  12.  
  13.      _i_n_t
  14.      dduupp22(_i_n_t _o_l_d_d, _i_n_t _n_e_w_d)
  15.  
  16. DDEESSCCRRIIPPTTIIOONN
  17.      DDuupp() duplicates an existing object descriptor and returns its value to
  18.      the calling process (_n_e_w_d = dduupp(_o_l_d_d)). The argument _o_l_d_d is a small non­
  19.      negative integer index in the per­process descriptor table.  The value
  20.      must be less than the size of the table, which is returned by
  21.      getdtablesize(2).  The new descriptor returned by the call is the lowest
  22.      numbered descriptor currently not in use by the process.
  23.  
  24.      The object referenced by the descriptor does not distinguish between _o_l_d_d
  25.      and _n_e_w_d in any way.  Thus if _n_e_w_d and _o_l_d_d are duplicate references to
  26.      an open file, read(2),  write(2) and lseek(2) calls all move a single
  27.      pointer into the file, and append mode, non­blocking I/O and asynchronous
  28.      I/O options are shared between the references.  If a separate pointer in­
  29.      to the file is desired, a different object reference to the file must be
  30.      obtained by issuing an additional open(2) call.  The close­on­exec flag
  31.      on the new file descriptor is unset.
  32.  
  33.      In dduupp22(), the value of the new descriptor _n_e_w_d is specified.  If this
  34.      descriptor is already in use, the descriptor is first deallocated as if a
  35.      close(2) call had been done first.
  36.  
  37. RREETTUURRNN VVAALLUUEESS
  38.      The value ­1 is returned if an error occurs in either call.  The external
  39.      variable _e_r_r_n_o indicates the cause of the error.
  40.  
  41. EERRRROORRSS
  42.      DDuupp() and dduupp22() fail if:
  43.  
  44.      [EBADF]       _O_l_d_d or _n_e_w_d is not a valid active descriptor
  45.  
  46.      [EMFILE]      Too many descriptors are active.
  47.  
  48. SSEEEE AALLSSOO
  49.      accept(2),  open(2),  close(2),  fcntl(2),  pipe(2),  socket(2),
  50.      socketpair(2),  getdtablesize(2)
  51.  
  52. SSTTAANNDDAARRDDSS
  53.      DDuupp() and dduupp22() are expected to conform to IEEE Std 1003.1­1988
  54.      (``POSIX'').
  55.  
  56. 4th Berkeley Distribution       March 10, 1991                               1
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.