rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 1 | .TH DUP 3 |
| 2 | .SH NAME |
| 3 | dup \- duplicate an open file descriptor |
| 4 | .SH SYNOPSIS |
| 5 | .B #include <u.h> |
| 6 | .br |
| 7 | .B #include <libc.h> |
| 8 | .PP |
| 9 | .B |
| 10 | int dup(int oldfd, int newfd) |
| 11 | .SH DESCRIPTION |
| 12 | Given a file descriptor, |
| 13 | .IR oldfd , |
| 14 | referring to an open file, |
| 15 | .I dup |
| 16 | returns a new file descriptor referring to the same file. |
| 17 | .PP |
| 18 | If |
| 19 | .I newfd |
| 20 | is \-1 the system chooses the lowest available file descriptor. |
| 21 | Otherwise, |
| 22 | .I dup |
| 23 | will use |
| 24 | .I newfd |
| 25 | for the new file descriptor |
| 26 | (closing any old file associated with |
| 27 | .IR newfd ). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 28 | .SH SOURCE |
rsc | c3674de | 2005-01-11 17:37:33 +0000 | [diff] [blame] | 29 | .B \*9/src/lib9/dup.c |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 30 | .SH DIAGNOSTICS |
| 31 | Sets |
| 32 | .IR errstr . |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 33 | .SH BUGS |
rsc | c8b6342 | 2005-01-13 04:49:19 +0000 | [diff] [blame] | 34 | To avoid name conflicts with the underlying system, |
| 35 | .I dup |
| 36 | is a preprocessor macro defined as |
| 37 | .IR p9dup ; |
| 38 | see |
rsc | 058b011 | 2005-01-03 06:40:20 +0000 | [diff] [blame] | 39 | .IR intro (3). |