Commit | Line | Data |
---|---|---|
2cf6fecc C |
1 | |
2 | ||
3 | ||
4 | DUP(2) UNIX Programmer's Manual DUP(2) | |
5 | ||
6 | ||
7 | ||
8 | N\bNA\bAM\bME\bE | |
9 | dup, dup2 - duplicate a descriptor | |
10 | ||
11 | S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS | |
12 | n\bne\bew\bwd\bd =\b= d\bdu\bup\bp(\b(o\bol\bld\bdd\bd)\b) | |
13 | i\bin\bnt\bt n\bne\bew\bwd\bd,\b, o\bol\bld\bdd\bd;\b; | |
14 | ||
15 | d\bdu\bup\bp2\b2(\b(o\bol\bld\bdd\bd,\b, n\bne\bew\bwd\bd)\b) | |
16 | i\bin\bnt\bt o\bol\bld\bdd\bd,\b, n\bne\bew\bwd\bd;\b; | |
17 | ||
18 | D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN | |
19 | _\bD_\bu_\bp duplicates an existing object descriptor. The argument | |
20 | _\bo_\bl_\bd_\bd is a small non-negative integer index in the per- | |
21 | process descriptor table. The value must be less than the | |
22 | size of the table, which is returned by _\bg_\be_\bt_\bd_\bt_\ba_\bb_\bl_\be_\bs_\bi_\bz_\be(2). | |
23 | The new descriptor returned by the call, _\bn_\be_\bw_\bd, is the lowest | |
24 | numbered descriptor that is not currently in use by the pro- | |
25 | cess. | |
26 | ||
27 | The object referenced by the descriptor does not distinguish | |
28 | between references using _\bo_\bl_\bd_\bd and _\bn_\be_\bw_\bd in any way. Thus if | |
29 | _\bn_\be_\bw_\bd and _\bo_\bl_\bd_\bd are duplicate references to an open file, | |
30 | _\br_\be_\ba_\bd(2), _\bw_\br_\bi_\bt_\be(2) and _\bl_\bs_\be_\be_\bk(2) calls all move a single | |
31 | pointer into the file, and append mode, non-blocking I/O and | |
32 | asynchronous I/O options are shared between the references. | |
33 | If a separate pointer into the file is desired, a different | |
34 | object reference to the file must be obtained by issuing an | |
35 | additional _\bo_\bp_\be_\bn(2) call. The close-on-exec flag on the new | |
36 | file descriptor is unset. | |
37 | ||
38 | In the second form of the call, the value of _\bn_\be_\bw_\bd desired is | |
39 | specified. If this descriptor is already in use, the | |
40 | descriptor is first deallocated as if a _\bc_\bl_\bo_\bs_\be(2) call had | |
41 | been done first. | |
42 | ||
43 | R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bE | |
44 | The value -1 is returned if an error occurs in either call. | |
45 | The external variable _\be_\br_\br_\bn_\bo indicates the cause of the | |
46 | error. | |
47 | ||
48 | E\bER\bRR\bRO\bOR\bRS\bS | |
49 | _\bD_\bu_\bp and _\bd_\bu_\bp_\b2 fail if: | |
50 | ||
51 | [EBADF] _\bO_\bl_\bd_\bd or _\bn_\be_\bw_\bd is not a valid active descriptor | |
52 | ||
53 | [EMFILE] Too many descriptors are active. | |
54 | ||
55 | S\bSE\bEE\bE A\bAL\bLS\bSO\bO | |
56 | accept(2), open(2), close(2), fcntl(2), pipe(2), socket(2), | |
57 | socketpair(2), getdtablesize(2) | |
58 | ||
59 | ||
60 | ||
61 | ||
62 | ||
63 | Printed 7/9/88 May 13, 1986 1 | |
64 | ||
65 | ||
66 |