Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup2(2) — DG/UX 5.4.2A

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept(2)

close(2)

creat(2)

dup(2)

exec(2)

fcntl(2)

getdtablesize(2)

open(2)

pipe(2)

socket(2)

socketpair(2)



dup2(2)                          DG/UX 5.4.2                         dup2(2)


NAME
       dup2 - duplicate an open file descriptor onto a specific descriptor

SYNOPSIS
       int  dup2 (oldfildes, newfildes)
       int  oldfildes;
       int  newfildes;

   where:
       oldfildes     A valid, active file descriptor

       newfildes     Another file descriptor

DESCRIPTION
       Dup2 combines the functionality of the dup and close operations.

       If oldfildes is an active, valid descriptor and newfildes is a
       valid descriptor (active or not), newfildes is made a duplicate of
       oldfildes.  If oldfildes and newfildes already refer to the same
       object pointer, no changes occur.  In all other situations in which
       newfildes is active, it is closed before being made a duplicate of
       oldfildes.  The close-on-exec flag is set so the descriptor remains
       open across exec(2) operations.  For a further discussion of the
       semantics of duplication and closing, see the dup and close
       operations respectively.

       If oldfildes equals newfildes, no changes occur.  However, an error
       will be returned if oldfildes is not an active, valid descriptor.

       Per-process descriptors are numbered from 0 to the system upper limit
       on per-process descriptors, MAX_PP_DESCRIPTORS.  They are also
       bounded above by the hard and soft file descriptor limits for the
       calling process (see open(2)).  Shared file descriptors are numbered
       from MAX_PP_DESCRIPTORS+1 to MAX_SHARED_DESCRIPTORS.  Dup2(2) can
       duplicate a descriptor of one class into a descriptor of another
       class.

ACCESS CONTROL
       None.

RETURN VALUE
       newfildes     The value of the new file descriptor given by
                      newfildes.

       -1             An error occurred.  errno is set to indicate the
                      error.

DIAGNOSTICS
       Errno may be set to one of the following error codes:

       EBADF     Oldfildes is not a valid, active descriptor.

       EBADF     Newfildes is not a valid descriptor.




Licensed material--property of copyright holder(s)                         1




dup2(2)                          DG/UX 5.4.2                         dup2(2)


SEE ALSO
       accept(2), close(2), creat(2), dup(2), exec(2), fcntl(2),
       getdtablesize(2), open(2), pipe(2), socket(2), socketpair(2),
       dgattachtoshareddescriptors(2).

STANDARDS
       When using m88kbcs as the Software Development Environment target,
       the dup2 function will be emulated using BCS system calls.  Since
       this is an emulation requiring several BCS system calls, a slight
       performance degradation may be noticed in comparison to using dup2 in
       /lib/libc.a.














































Licensed material--property of copyright holder(s)                         2


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026