Annotation of cci/usr/src/man/man2/dup.2, revision 1.1

1.1     ! root        1: .TH DUP 2 "12 February 1983"
        !             2: .UC 4
        !             3: .SH NAME
        !             4: dup, dup2 \- duplicate a descriptor
        !             5: .SH SYNOPSIS
        !             6: .nf
        !             7: .ft B
        !             8: newd = dup(oldd)
        !             9: int newd, oldd;
        !            10: .PP
        !            11: .ft B
        !            12: dup2(oldd, newd)
        !            13: int oldd, newd;
        !            14: .fi
        !            15: .SH DESCRIPTION
        !            16: .I Dup
        !            17: duplicates an existing object descriptor.
        !            18: The argument \fIoldd\fP is a small non-negative integer index in
        !            19: the per-process descriptor table.  The value must be less
        !            20: than the size of the table, which is returned by
        !            21: .IR getdtablesize (2).
        !            22: The new descriptor
        !            23: .I newd
        !            24: returned by the call is the lowest numbered descriptor which is
        !            25: not currently in use by the process.
        !            26: .PP
        !            27: The object referenced by the descriptor does not distinguish
        !            28: between references using \fIoldd\fP and \fInewd\fP in any way.
        !            29: Thus if \fInewd\fP and \fIoldd\fP are duplicate references to an open
        !            30: file,
        !            31: .IR read (2),
        !            32: .IR write (2)
        !            33: and
        !            34: .IR lseek (2)
        !            35: calls all move a single pointer into the file.
        !            36: If a separate pointer into the file is desired, a different
        !            37: object reference to the file must be obtained by issuing an
        !            38: additional
        !            39: .IR open (2)
        !            40: call.
        !            41: .PP
        !            42: In the second form of the call, the value of
        !            43: .IR newd
        !            44: desired is specified.  If this descriptor is already
        !            45: in use, the descriptor is first deallocated as if a
        !            46: .IR close (2)
        !            47: call had been done first.
        !            48: .SH "RETURN VALUE
        !            49: The value \-1 is returned if an error occurs in either call.
        !            50: The external variable
        !            51: .I errno
        !            52: indicates the cause of the error.
        !            53: .SH "ERRORS
        !            54: .I Dup
        !            55: and
        !            56: .I dup2
        !            57: fail if:
        !            58: .TP 15
        !            59: [EBADF]
        !            60: \fIOldd\fP or
        !            61: \fInewd\fP is not a valid active descriptor
        !            62: .TP 15
        !            63: [EMFILE]
        !            64: Too many descriptors are active.
        !            65: .SH "SEE ALSO"
        !            66: accept(2),
        !            67: open(2),
        !            68: close(2),
        !            69: pipe(2),
        !            70: socket(2),
        !            71: socketpair(2),
        !            72: getdtablesize(2)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.