Mercurial > illumos > illumos-gate
annotate usr/src/man/man3c/dup2.3c @ 14022:19e11862653b
3713 Implement accept4()
3714 Implement pipe2()
3715 Implement dup3()
3716 Implement mkostemp() and mkostemps()
3719 so_socketpair syscall should preserve FD_CLOEXEC flag
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Garrett D'Amore <garrett@damore.org>
author | Theo Schlossnagle <jesus@omniti.com> |
---|---|
date | Thu, 11 Apr 2013 04:50:36 +0000 |
parents | 5b2854ecc12d |
children |
rev | line source |
---|---|
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
1 '\" te |
14022
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
2 .\" Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
3 .\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
4 .\" Copyright 1989 AT&T |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
5 .\" 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. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
6 .\" 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. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
7 .\" 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] |
14022
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
8 .TH DUP2 3C "Apr 19, 2013" |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
9 .SH NAME |
14022
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
10 dup2, dup3 \- duplicate an open file descriptor |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
11 .SH SYNOPSIS |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
12 .LP |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
13 .nf |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
14 #include <unistd.h> |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
15 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
16 \fBint\fR \fBdup2\fR(\fBint\fR \fIfildes\fR, \fBint\fR \fIfildes2\fR); |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
17 .fi |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
18 |
14022
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
19 .LP |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
20 .nf |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
21 \fBint\fR \fBdup3\fR(\fBint\fR \fIfildes\fR, \fBint\fR \fIfildes2\fR, \dBint\fR \fIflags\fR); |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
22 .fi |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
23 |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
24 .SH DESCRIPTION |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
25 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
26 .LP |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
27 The \fBdup2()\fR function causes the file descriptor \fIfildes2\fR to refer to |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
28 the same file as \fIfildes\fR. The \fIfildes\fR argument is a file descriptor |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
29 referring to an open file, and \fIfildes2\fR is a non-negative integer less |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
30 than the current value for the maximum number of open file descriptors allowed |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
31 the calling process. See \fBgetrlimit\fR(2). If \fIfildes2\fR already refers |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
32 to an open file, not \fIfildes\fR, it is closed first. If \fIfildes2\fR refers |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
33 to \fIfildes\fR, or if \fIfildes\fR is not a valid open file descriptor, |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
34 \fIfildes2\fR will not be closed first. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
35 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
36 .LP |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
37 The \fBdup2()\fR function is equivalent to \fBfcntl\fR(\fIfildes\fR, |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
38 \fBF_DUP2FD\fR, \fIfildes2\fR). |
14022
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
39 .sp |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
40 .LP |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
41 Ths \fBdup3()\fR function works similarly to the \fBdup2()\fR function with |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
42 two exceptions. If \fIfildes\fR and \fIfildes2\fR point to the same file |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
43 descriptor, -1 is returned and errno set to \fBEINVAL\fR. If \fIflags\fR |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
44 is \fBO_CLOEXEC\fR, then \fIfiledes2\fB will have the \fBFD_CLOEXEC\fR flag |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
45 set causing the file descriptor to be closed during any future call of |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
46 \fBexec\fR(2). |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
47 .SH RETURN VALUES |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
48 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
49 .LP |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
50 Upon successful completion a non-negative integer representing the file |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
51 descriptor is returned. Otherwise, \fB\(mi1\fR is returned and \fBerrno\fR is |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
52 set to indicate the error. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
53 .SH ERRORS |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
54 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
55 .LP |
14022
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
56 The \fBdup2()\fR and \fBdup3()\fR functions will fail if: |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
57 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
58 .ne 2 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
59 .na |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
60 \fB\fBEBADF\fR\fR |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
61 .ad |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
62 .RS 10n |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
63 The \fIfildes\fR argument is not a valid open file descriptor. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
64 .RE |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
65 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
66 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
67 .ne 2 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
68 .na |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
69 \fB\fBEBADF\fR\fR |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
70 .ad |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
71 .RS 10n |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
72 The \fIfildes2\fR argument is negative or is not less than the current resource |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
73 limit returned by \fBgetrlimit(RLIMIT_NOFILE, .\|.\|.)\fR. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
74 .RE |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
75 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
76 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
77 .ne 2 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
78 .na |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
79 \fB\fBEINTR\fR\fR |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
80 .ad |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
81 .RS 10n |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
82 A signal was caught during the \fBdup2()\fR call. |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
83 .RE |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
84 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
85 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
86 .ne 2 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
87 .na |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
88 \fB\fBEMFILE\fR\fR |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
89 .ad |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
90 .RS 10n |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
91 The process has too many open files. See \fBfcntl\fR(2). |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
92 .RE |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
93 |
14022
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
94 .sp |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
95 .LP |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
96 Additionally, the \fBdup3()\fR function will fail if: |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
97 .sp |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
98 .ne 2 |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
99 .na |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
100 \fB\fBEINVAL\fR\fR |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
101 .ad |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
102 .RS 10n |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
103 \fIflags\fR has a value other than 0 or \fBO_CLOEXEC\fR or \fIfildes\fR and \fIfildes2\fB point to the same file descriptor. |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
104 .RE |
19e11862653b
3713 Implement accept4()
Theo Schlossnagle <jesus@omniti.com>
parents:
13476
diff
changeset
|
105 |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
106 .SH ATTRIBUTES |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
107 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
108 .LP |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
109 See \fBattributes\fR(5) for descriptions of the following attributes: |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
110 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
111 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
112 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
113 .TS |
13476
5b2854ecc12d
1502 Remove conversion cruft from manpages
Yuri Pankov <yuri.pankov@nexenta.com>
parents:
13304
diff
changeset
|
114 box; |
5b2854ecc12d
1502 Remove conversion cruft from manpages
Yuri Pankov <yuri.pankov@nexenta.com>
parents:
13304
diff
changeset
|
115 c | c |
5b2854ecc12d
1502 Remove conversion cruft from manpages
Yuri Pankov <yuri.pankov@nexenta.com>
parents:
13304
diff
changeset
|
116 l | l . |
5b2854ecc12d
1502 Remove conversion cruft from manpages
Yuri Pankov <yuri.pankov@nexenta.com>
parents:
13304
diff
changeset
|
117 ATTRIBUTE TYPE ATTRIBUTE VALUE |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
118 _ |
13476
5b2854ecc12d
1502 Remove conversion cruft from manpages
Yuri Pankov <yuri.pankov@nexenta.com>
parents:
13304
diff
changeset
|
119 Interface Stability Standard |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
120 _ |
13476
5b2854ecc12d
1502 Remove conversion cruft from manpages
Yuri Pankov <yuri.pankov@nexenta.com>
parents:
13304
diff
changeset
|
121 MT-Level Async-Signal-Safe |
13304
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
122 .TE |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
123 |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
124 .SH SEE ALSO |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
125 .sp |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
126 .LP |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
127 \fBclose\fR(2), \fBcreat\fR(2), \fBexec\fR(2), \fBfcntl\fR(2), |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
128 \fBgetrlimit\fR(2), \fBopen\fR(2), \fBpipe\fR(2), \fBattributes\fR(5), |
b54231762cfa
243 system manual pages should live with the software
Richard Lowe <richlowe@richlowe.net>
parents:
diff
changeset
|
129 \fBstandards\fR(5) |