summaryrefslogtreecommitdiff
path: root/usr/src/man/man2/dup.2
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/man/man2/dup.2')
-rw-r--r--usr/src/man/man2/dup.2132
1 files changed, 132 insertions, 0 deletions
diff --git a/usr/src/man/man2/dup.2 b/usr/src/man/man2/dup.2
new file mode 100644
index 0000000000..dc0d066dae
--- /dev/null
+++ b/usr/src/man/man2/dup.2
@@ -0,0 +1,132 @@
+'\" te
+.\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
+.\" 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.
+.\" 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.
+.\" 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]
+.TH dup 2 "28 Dec 1996" "SunOS 5.11" "System Calls"
+.SH NAME
+dup \- duplicate an open file descriptor
+.SH SYNOPSIS
+.LP
+.nf
+#include <unistd.h>
+
+\fBint\fR \fBdup\fR(\fBint\fR \fIfildes\fR);
+.fi
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBdup()\fR function returns a new file descriptor having the following in
+common with the original open file descriptor \fIfildes\fR:
+.RS +4
+.TP
+.ie t \(bu
+.el o
+same open file (or pipe)
+.RE
+.RS +4
+.TP
+.ie t \(bu
+.el o
+same file pointer (that is, both file descriptors share one file pointer)
+.RE
+.RS +4
+.TP
+.ie t \(bu
+.el o
+same access mode (read, write or read/write).
+.RE
+.sp
+.LP
+The new file descriptor is set to remain open across \fIexec\fR functions (see
+\fBfcntl\fR(2)).
+.sp
+.LP
+The file descriptor returned is the lowest one available.
+.sp
+.LP
+The \fBdup(\fR\fIfildes\fR\fB)\fR function call is equivalent to:
+.sp
+.LP
+\fBfcntl(\fR\fIfildes\fR\fB, F_DUPFD, 0)\fR
+.SH RETURN VALUES
+.sp
+.LP
+Upon successful completion, a non-negative integer representing the file
+descriptor is returned. Otherwise, \fB\(mi1\fR is returned and \fBerrno\fR is
+set to indicate the error.
+.SH ERRORS
+.sp
+.LP
+The \fBdup()\fR function will fail if:
+.sp
+.ne 2
+.mk
+.na
+\fB\fBEBADF\fR\fR
+.ad
+.RS 11n
+.rt
+The \fIfildes\fR argument is not a valid open file descriptor.
+.RE
+
+.sp
+.ne 2
+.mk
+.na
+\fB\fBEINTR\fR\fR
+.ad
+.RS 11n
+.rt
+A signal was caught during the execution of the \fBdup()\fR function.
+.RE
+
+.sp
+.ne 2
+.mk
+.na
+\fB\fBEMFILE\fR\fR
+.ad
+.RS 11n
+.rt
+The process has too many open files (see \fBgetrlimit\fR(2)).
+.RE
+
+.sp
+.ne 2
+.mk
+.na
+\fB\fBENOLINK\fR\fR
+.ad
+.RS 11n
+.rt
+The \fIfildes\fR argument is on a remote machine and the link to that machine
+is no longer active.
+.RE
+
+.SH ATTRIBUTES
+.sp
+.LP
+See \fBattributes\fR(5) for descriptions of the following attributes:
+.sp
+
+.sp
+.TS
+tab() box;
+cw(2.75i) |cw(2.75i)
+lw(2.75i) |lw(2.75i)
+.
+ATTRIBUTE TYPEATTRIBUTE VALUE
+_
+Interface StabilityStandard
+_
+MT-LevelAsync-Signal-Safe
+.TE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBclose\fR(2), \fBcreat\fR(2), \fBexec\fR(2), \fBfcntl\fR(2),
+\fBgetrlimit\fR(2), \fBopen\fR(2), \fBpipe\fR(2), \fBdup2\fR(3C),
+\fBlockf\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)