Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup2(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

creat(S)

close(S)

exec(S)

fcntl(S)

lockf(S)

open(S)

pipe(S)


 dup2(S)                        6 January 1993                        dup2(S)


 Name

    dup2 - duplicate an open file descriptor

 Syntax


    cc  . . .  -lc


    int dup2 (fildes, fildes2)
    int fildes, fildes2;


 Description

    The fildes argument is a file descriptor referring to an open file, and
    fildes2 is a non-negative integer less than NFILE. dup2 causes fildes2
    to refer to the same file as fildes. If fildes2 already referred to an
    open file, it is closed first.

    The dup2 function fails if one or more of the following is true:

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

    [EMFILE]    NFILE file descriptors are currently open.


 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

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

 Standards conformance

    dup2 is conformant with:
    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