2 .\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH DUP 2 "Dec 28, 1996"
8 dup \- duplicate an open file descriptor
14 \fBint\fR \fBdup\fR(\fBint\fR \fIfildes\fR);
20 The \fBdup()\fR function returns a new file descriptor having the following in
21 common with the original open file descriptor \fIfildes\fR:
26 same open file (or pipe)
32 same file pointer (that is, both file descriptors share one file pointer)
38 same access mode (read, write or read/write).
42 The new file descriptor is set to remain open across \fIexec\fR functions (see
46 The file descriptor returned is the lowest one available.
49 The \fBdup(\fR\fIfildes\fR\fB)\fR function call is equivalent to:
52 \fBfcntl(\fR\fIfildes\fR\fB, F_DUPFD, 0)\fR
56 Upon successful completion, a non-negative integer representing the file
57 descriptor is returned. Otherwise, \fB\(mi1\fR is returned and \fBerrno\fR is
58 set to indicate the error.
62 The \fBdup()\fR function will fail if:
69 The \fIfildes\fR argument is not a valid open file descriptor.
78 A signal was caught during the execution of the \fBdup()\fR function.
87 The process has too many open files (see \fBgetrlimit\fR(2)).
96 The \fIfildes\fR argument is on a remote machine and the link to that machine
103 See \fBattributes\fR(5) for descriptions of the following attributes:
111 ATTRIBUTE TYPE ATTRIBUTE VALUE
113 Interface Stability Standard
115 MT-Level Async-Signal-Safe
121 \fBclose\fR(2), \fBcreat\fR(2), \fBexec\fR(2), \fBfcntl\fR(2),
122 \fBgetrlimit\fR(2), \fBopen\fR(2), \fBpipe\fR(2), \fBdup2\fR(3C),
123 \fBlockf\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)