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