Research V3 development
[unix-history] / man / man2 / dup.2
CommitLineData
14d442b8
KT
1.pa 1
2.he 'DUP (II)'1/15/73'DUP (II)'
3.ti 0
4NAME dup -- duplicate an open file descriptor
5.sp
6.ti 0
7SYNOPSIS (file descriptor in r0)
8.br
9sys dup / dup = 41.; not in assembler
10.br
11(file descriptor in r0)
12.sp
13.ti 0
14DESCRIPTION Given
15a file descriptor returned from
16an open or creat call,
17dup\b\b\b___
18will allocate another file descriptor
19synonymous
20with
21the original.
22The new file descriptor is returned in r0.
23.sp
24Dup\b\b\b___
25is used more to manipulate the value
26of file descriptors
27than to genuinely
28duplicate a file descriptor.
29Since the algorithm to allocate
30file descriptors
31is known to use the
32lowest available
33value between 0 and 9,
34combinations of dup\b\b\b___
35and close\b\b\b\b\b_____ can be
36used to
37manipulate file descriptors
38in a general way.
39This is handy for
40manipulating standard input and/or
41standard output.
42.sp
43.ti 0
44SEE ALSO creat(II), open(II), close(II)
45.sp
46.ti 0
47DIAGNOSTICS The
48error bit (c-bit)
49is set if:
50the given file descriptor is invalid;
51there are already 10 open files.
52.sp
53.ti 0
54BUGS --