Blob


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 ).
28 .SH SOURCE
29 .B \*9/src/lib9/dup.c
30 .SH DIAGNOSTICS
31 Sets
32 .IR errstr .
33 .SH BUGS
34 To avoid name conflicts with the underlying system,
35 .I dup
36 is a preprocessor macro defined as
37 .IR p9dup ;
38 see
39 .MR intro (3) .