Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup(2) — sys5 — Apollo Domain/OS SR10.4.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dup2(3C)

close(2)

creat(2)

exec(2)

fcntl(2)

open(2)

pipe(2)

lockf(3C)

DUP(2)                               SysV                               DUP(2)



NAME
     dup - duplicate an open file descriptor

SYNOPSIS
     int dup (fildes)
     int fildes;

DESCRIPTION
     The dup function provides an alternate interface to the service provided
     by the fcntl(2) function using the F_DUPFD command. The call

          fid = dup (fildes);

     is equivalent to:

          fid = fcntl (fildes, F_DUPFD, 0);

     fildes is a file descriptor obtained from a creat, open, dup, fcntl, or
     pipe system call.  dup returns a new file descriptor having the following
     in common with the original:

     +  Same open file (or pipe).

     +  Same file pointer (that is, both file descriptors share one file
        pointer).

     +  Same access mode (read, write, or read/write).

     The new file descriptor is set to remain open across exec system calls.
     See fcntl(2).

     The file descriptor returned is the lowest one available.

DIAGNOSTICS
     A successful call returns a non-negative integer file descriptor.  A
     failed call returns -1 and sets errno as indicated under "Errors."

ERRORS
     dup fails if one or more of the following are true:

     [EBADF]     fildes is not a valid open file descriptor.

     [EINTR]     A signal was caught during the dup system call.

     [EMFILE]    The maximum number of open file descriptors allowed would be
                 exceeded.  [EINTR] The dup function was terminated
                 prematurely by a signal.

SEE ALSO
     dup2(3C), close(2), creat(2), exec(2), fcntl(2), open(2), pipe(2),
     lockf(3C).

NOTES
     Under other implementations, dup fails if the following is true:

     [ENOLINK]   fildes is on a remote machine and the link to that machine is
                 no longer active.

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