Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(S)

creat(S)

exec(S)

fcntl(S)

open(S)

pipe(S)

lockf(S)


 dup(S)                         6 January 1993                         dup(S)


 Name

    dup - duplicate an open file descriptor

 Syntax


    cc  . . .  -lc


    int dup (fildes)
    int fildes;


 Description

    The fildes argument is a file descriptor obtained from a creat, open,
    dup, fcntl, or pipe system call.  The dup system call 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(S).

    The file descriptor returned is the lowest one available.

    The dup system call fails if one or more of the following is true:

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

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

    [EMFILE]    NFILE file descriptors are currently open.

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


 Diagnostics

    Upon successful completion a non-negative integer, namely the file
    descriptor, is returned.  Otherwise, a value of -1 is returned, and errno
    is set to indicate the error.

 See also

    close(S), creat(S), exec(S), fcntl(S), open(S), pipe(S), lockf(S)

 Standards conformance

    dup is conformant with:
    AT&T SVID Issue 2;
    X/Open Portability Guide, Issue 3, 1989;
    IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C
    Language] (ISO/IEC 9945-1);
    and NIST FIPS 151-1.


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